I successfully created my first AppImage. It contains a Qt application. Now I want to add static (read-only) xml data files into the AppImage but I don’t get it work.
I have two questions:
What is the best place to add the files? I thought about AppDir/usr/share/appname/*.xml but I am not sure if there is a better place.
How can I access the files from within my application? I inspected QDir::current().absolutePath() and QFileInfo(".").absolutePath() but both paths are located out of the AppImage tree.
Assuming I understand what you are trying to do, I would (and do in my application) use the QT resource system which will include your xml files in the application’s executable.
From within your application you then access the file using a path similar to this: “:/res/filename.xml”. This has the advantage that it will work in the same way whether or not your application is packaged as an AppImage.
I see. I already use the resource way for icons and similar stuff.
And I surly could rewrite my application regarding resource file handling (actually the application was not designed having AppImages in mind) but I assumed it should be very simple to access data files in the AppImage if I knew how to do it.
I would also need to rethink some other ideas since I planned to integrate custom files with the AppImage via the AppImage creation script (without rebuilding the application).
Is there really no easy solution for accessing data files within the AppImage?!
You can absolutely put it there if you like. But you need to make sure to load it from a path relative to your main application file, rather than from an absolute path or a path relative to the user’s current directory (cwd).