_getInstallPath()

NAME

_getInstallPath(), _prefixInstallPath(), _getInstallPath_Win(), _prefixInstallPath_Win() - find root of Interix install path

SYNOPSIS

#include <interix/interix.h>

char * _getInstallPath(void)
char * _getInstallPath_Win(void)
char * _prefixInstallPath( const char *name, char *buf, int len )
char * _prefixInstallPath_Win( const char *name, char *buf, int len )

DESCRIPTION

These functions retrieve the pathname for the directory where Interix was installed. If you installed the Interix Commands and Utilities in the default location (usually /dev/fs/C/SFU/), then the pathname is /dev/fs/C/SFU/.

_getInstallPath(3) returns the pathname itself. It looks in the registry for the entry HKEY_LOCAL_MACHINE/Software/Microsoft/Services for UNIX/InstallRoot and stores the value in a static buffer. It returns a pointer to that buffer. The pathname always ends in /.

The _getInstallPath_Win(3) call does the same, but the pathname is returned in the Windows format. The Windows pathname is retrieved from the registry entry: HKEY_LOCAL_MACHINE/Software/Microsoft/Services for UNIX/InstallRoot_Win.

The _prefixInstallPath(3) call prefixes the installed-root directory onto another path (specified by name) and returns a pointer to the concatenated name. If buf is NULL, then the concatenated name is stored in a static buffer; if buf is non-NULL, the concatenated name is stored there. If you specify buf, you must also specify a non-zero value for len, the number of bytes that buf will hold.

The _prefixInstallPath_Win(3) call performs the transformation as _prefixInstallPath(3), but the pathname is in the Windows format.

The _getInstallPath(3) and _prefixInstallPath(3) calls are legacies, predating the single-rooted file system on Interix.

RETURN CODES

The _getInstallPath(3) and _getInstallPath_Win(3) functions return a pointer to a static buffer, or NULL on failure. They can fail for one of these reasons:

The _prefixInstallPath(3) and _prefixInstallPath_Win(3) functions return a pointer to the concatenated path. They can return NULL for one of the following errors:

EXAMPLE

Many traditional programs define paths as static strings. For example:

#define PAGER "/bin/more"
...
printf("Using %s as the pager\n", PAGER);

A trivial conversion which ignores the possibility of failure is:

#ifndef __INTERIX
# define PAGER "/bin/more"
#else
# define PAGER _prefixInstallPath("/bin/more",NULL,0)
#endif /* __INTERIX */
...
printf("Using %s as the pager\n", PAGER);

SEE ALSO

confstr(3)