[Proj] Finding PROJ_LIB from application
Glynn Clements
glynn at gclements.plus.com
Thu Jan 15 12:05:08 PST 2009
Roger Bivand wrote:
> Is there any way to query the system for the path to lib - effectively the
> path value in sysname in pj_open_lib.c, line 184? From inside R, I'd like
> to be able to show which path is being used.
There doesn't appear to be any explicit support for this, but there
are a couple of hacks available if "don't know" isn't fatal:
1. Set PROJ_DEBUG, (temporarily) point stderr at a file, and parse the
filename out of the debug message (which could contain other text if
library functions or the finder function write to stderr).
2. Make a copy of pj_open_lib() which returns the path rather than
opening it, call fstat(fileno(fp)) and stat(pathname), and check that
the dev/inode match.
3. On Linux, use fileno() to get a descriptor from the returned FILE*
and look up the filename in /proc/self/fd/<fd>. Some other Unices
support /proc, but I don't know how consistent they are.
4. On Windows, GetFinalPathNameByHandle(_get_osfhandle(_fileno(fp))).
--
Glynn Clements <glynn at gclements.plus.com>
More information about the Proj
mailing list