Reputation: 35
I have a small program in QtCreator, but where i can store data from user, if that program not have a root privileges to create dir for example in /usr/bin/myappname. I can't have a root privileges because my program is distributed like appimage and I like to start that image like normal user, not root. maybe I can store data to /home/user/myappname but if user have other language in his OS home dir do no have to exist.
Upvotes: 1
Views: 53
Reputation: 238351
where I can store data /C++
if that program not have a root privileges
One approach is to have the package manager create the directories with super user privileges when the program is installed. This approach works only when the program is installed using a package manager. This is typical choice for daemons such as servers.
Another approach is to store the data within the home directory of the user, where the process presumably has the privilege to create the directories. This is typical choice for interactive applications.
The exact location where you should store the data depends on the system where you are running the process. Different operating systems have different conventions. It also depends on what kind of data you are storing. Is it temporary? Is it CPU architecture dependent? Is it for configuration? Is it log files?
For Linux and other POSIX systems, follow the XDG Base Directory Specification. Also study Filesystem Hierarchy Standard. For other systems, consult their documentation for best practices.
I can store data to /home/user/myappname but if user have other language in his OS home dir do no have to exist.
Don't assume the path of the home directory. Use the HOME
environment variable.
Upvotes: 1