Best place to put external files?

OK so I've been working on some applications for FreeBSD, but they use plenty of external files (content, configuration, etc). One of them is a game, the other is a desktop utility. In "Windows world", I would simply put such files in subdirectories where the binary is. However, I noticed that when you start a program from Konqueror, this doesn't tend to work since the path returned is the home directory of the user rather than the path of the binary you are running. Obviously it works fine from the console, but not all users use the console. So what I did to work around this was to select a base directory that is pretty much guaranteed to exist on all FreeBSD systems, which would be /usr/local/share. So what I ended up with is /usr/local/share/eponasoft/appname/subdirs*/data*. Is this considered proper form, or is there a better, more standardized way of doing things? For the game, I could probably consider putting the files at ~/.whatever, but that won't work for the desktop utility since it needs to be accessible to anyone on the system. The desktop utility keeps user profile information in a subdir off of the user's home dir, but it also has content that can be downloaded that is accessible to every user who uses it.

Also, since these are to be cross-platform applications, does anyone have a recommendation for how this could be done on a Linux machine? For a Windows machine, I already have the process ironed out, so that's not a problem, but I'm unfamiliar with the standard Linux filesystem hierarchy...if such a thing exists. :)
 
It depends what you are storing.

Configuration files:
/usr/local/etc

Documentation:
/usr/local/share/doc/<projectname>

Libraries:
/usr/local/lib

Headers:
/usr/local/include

Generic data:
/usr/local/share/<projectname>

Binaries:
/usr/local/bin and /usr/local/sbin

Binary plugins:
/usr/local/libexec

Man pages:
/usr/local/man

Info pages:
/usr/local/info


If you don't want to split things up by type, I believe the accepted practice is:
/usr/local/<projectname>

I guess /usr/local/eponasoft would be acceptable.
 
Well, it's that I noticed several other applications dumping stuff into /usr/local/share so I figured it was the right place. For example, there are almost 30 gnome directories there on my system and I don't even use gnome...
 
OK so it looks like I was right for using /usr/local/share and ~/.app. Thanks everyone. :) I tried downloading and installing a minimalist Linux (called aLinux) to see if it set up the hierarchy the same way but it refused to install...it just kinda hung while installing (a common problem with the typical hack Linux, it seems).
 
"Linux" uses a very different directory layout. It's "documented" in the Filesystem Hierarchy Standard (FHS). However, each distro uses a modified, custom version of the FHS (which is why I consider it "documented").

The big differences from FreeBSD are:
  • everything is installed into /usr with configs for everything under /etc (no separation of OS from apps)
  • /usr/local is only for stuff manually compiled by the sysadmin
  • /opt is for third-party binary installs
 
That would suck. :(

Well, this project has been boatloads of fun. Plenty to learn about when it comes to doing directory strings...like don't try to fopen "~/.directory/file" or it will segfault. :) getlogin_r() followed by getpwnam() worked, though I did see people suggesting getenv("HOME") though that can apparently be spoofed and I'd prefer not to have that happen. I'm so not used to dealing with variable paths...I've only ever done absolute paths in C. Ah well...forward march! :D
 
vivek said:
User specific config should go in ~/.appname/ directory. For example, my vim config will go in ~/.vimrc file.
Is the ~/.config directory a "legacy" way for storing configuration files?
 
AFAIK ~/.config is used by some Gnome / Gtk apps.
 
Sounds about right.

Code:
~/.config]$ ls
Google		autostart	geeqie		orage		xfce4-session
Terminal	en.dic		gtk-2.0		ristretto
Thunar		en.exc		midori		vlc
Trolltech.conf	enchant		mousepad	xfce4
 
Back
Top