Hard coding paths in Linux

Coming from the background of Windows.

Is it a good practice for Linux GUI applications to store their data files (non-user) in hard-coded places (e.g. / etc / myapp / stuff)? I could not find any system calls that would return the preferred directory for application data. Is there a convention on what's going on?

+5
source share
6 answers

Generally speaking, yes, there is a convention. On most Linux systems, application configuration files are usually located at /etc/appname/. You will want to check out LSB (the standard Linux base) and Linux FHS (the standard file system hierarchy) for relevant recommendations.

Also, if you are targeting your application to a specific Linux distribution, that distribution provider probably has its own specific recommendations regarding packaging and related conventions. For more information, you will want to look at the pages of the developers of the distribution developers.

+4
source

/opt/appname/stuffin accordance with the Linux File System Hierarchy Standard

, , . ?

+5

/etc. (-, , ..) /var. , . , (/etc | /var), appname , .

, - . , (XDG) ~/.config ~/.cache / , .

, : ~/.cache ~/.config ~/.irssi ~/.maildir ~/.mozilla ~/.kde ~/.ssh ~/.vnc

[]
syscall, XDG, , http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html

+3

.

  • , / () /etc/appname/.
  • (, ) /var/*/appname/ - /var/cache/appname/, /var/spool/appname/ /var/lib/appname/.
  • , , , (, ), /usr/share/appname/.
+2

, Unix/Linux/GNU , , . ( , strings(1) ).

, , . , , , . ( ), .

+1

Linux ( , ..). .

If you are encoding a GUI application, you should study the toolkit documentation to see if it provides a mechanism for managing default settings. As KDE and Gnome there is, for example.

0
source

All Articles