PDA

View Full Version : Distribute app with directories intacked



tndave
28th July 2018, 17:33
Good afternoon everyone,

I have a question I am hoping someone can help with. I was trying to find out if, when an app is finally built, if there is a way to keep a directory structure within the final build so that the directories are able to distributed with the app?

Example, if I build an app with a "doc" directory and an "image" directory, is there a way to keep those directories once the app is built successfully. (I kinda like structure in my apps lol)

Would like to be able to do this and when I distribute the app all the user has to do is unzip it, all directories will be there, and then run when needed. If anyone can give some insight on this I would greatly appreciate it. QT has been such a pleasure to work with that I have literally stopped using MS Visual Studio, which was the only thing keeping me using windows.

Many thanks for any assistance :)

d_stranz
29th July 2018, 19:13
If your application relies on having hard-coded paths to places where it accesses files (a really, really bad idea most of the time, by the way), then there are any number of ways to ensure that:

- use an actual installer that creates (and populates) these directories when your app is installed
- look for and create the directories when the app is run up if they don't exist
- if you distribute your app as a zip file, then add those directories when you create the zip file. They will be created when the file is unzipped.

Why is it a really, really bad idea to create hard-coded directories?

- On Windows 10, apps run with ordinary User permission aren't allowed to create files or directories in Program Files or Program Files (x86)
- Having hard-coded files runs counter to the Windows preferred method of having app-specific data in AppData and user-specific data under Users.
- Maybe the user has a small solid state disk as a C: drive, and doesn't want it cluttered up with app-related data files, or maybe has several PCs and keeps the stuff he wants to move from PC to PC on a removable USB drive (like I do).

Qt has a whole set of OS-friendly ways to create App and User-specific files at run-time (see QStandardPaths), as well as to run standard programs (see QDesktopServices). You can also Google for Qt Windows deployment and read all about what is required to successfully deploy a Qt app on a system where no Qt development tools are installed.

tndave
29th July 2018, 21:04
d_stranz

Thank you very much for your reply. I appreciate the information and it makes very good sense, got me thinking twice about doing it now lol. I also appreciate the links to the documentation for this. Was doing some searching but wasn't sure what to look for in regards to the classes etc. that this specific question fell into. I will be reading through them today to learn more. :)

Many thanks :)