Re: [Vala] Fwd: Getting path to my program's directory



Mark Dewey wrote:
No. It doesn't work. If it did work, then sure, I'd be serious. At the
very least it would give you to know there was a way to do it.

From what I've read there is no portable way to determine the path to a
running executable.  On various OS's that support /proc, you can often
glean the path from there.  For example on linux, /proc/<pid#>/exe is
supposed to be a symlink to the original executable.  You can use
readlink to determine the path.  On BSD, there's a different entry that
contains the actual posix path.

Seems like when I've encountered people asking about this on Linux
forums, invariably bigots come on and say, "why would you want to know
this?" or "needing to know the path of the execution is really bad
design."  Whether this is true or not I cannot say.  Generally the unix
way is to follow certain standards for placing data files.  IE if you're
installed for the whole system you put data files in /usr/share or
/usr/lib/yourapp/.  Libraries would be in /usr/lib (or /usr/lib64) and
plugins typically in /usr/lib/<yourapp>/.  Configs in the home directory
under a dot file (what a mess), or under the new freedesktop standards
location, $HOME/.config[1].  Most programs use macro variables that are
set at compile time to set these paths.  Since package managers are
normally used, this works very well.

The idea of self-contained, relocatable packages, does not seem to hold
sway in the Linux world.  Maybe it should.  I don't know.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]