2006-10-19 19:50:23 +08:00
|
|
|
/** \file path.h
|
|
|
|
|
|
|
|
Directory utilities. This library contains functions for locating
|
|
|
|
configuration directories, for testing if a command with a given
|
|
|
|
name can be found in the PATH, and various other path-related
|
|
|
|
issues.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FISH_PATH_H
|
|
|
|
#define FISH_PATH_H
|
|
|
|
|
2008-01-14 00:47:47 +08:00
|
|
|
/**
|
|
|
|
Return value for path_cdpath_get when locatied a rotten symlink
|
|
|
|
*/
|
2007-09-21 01:52:43 +08:00
|
|
|
#define EROTTEN 1
|
|
|
|
|
2006-10-19 19:50:23 +08:00
|
|
|
/**
|
|
|
|
Returns the user configuration directory for fish. If the directory
|
|
|
|
or one of it's parents doesn't exist, they are first created.
|
|
|
|
|
|
|
|
\param context the halloc context to use for memory allocations
|
|
|
|
\return 0 if the no configuration directory can be located or created, the directory path otherwise.
|
|
|
|
*/
|
|
|
|
wchar_t *path_get_config( void *context);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Finds the full path of an executable in a newly allocated string.
|
|
|
|
|
|
|
|
\param cmd The name of the executable.
|
|
|
|
\param context the halloc context to use for memory allocations
|
|
|
|
\return 0 if the command can not be found, the path of the command otherwise.
|
|
|
|
*/
|
|
|
|
wchar_t *path_get_path( void *context, const wchar_t *cmd );
|
|
|
|
|
|
|
|
/**
|
2007-09-21 01:52:43 +08:00
|
|
|
Returns the full path of the specified directory, using the CDPATH
|
|
|
|
variable as a list of base directories for relative paths. The
|
|
|
|
returned string is allocated using halloc and the specified
|
|
|
|
context.
|
|
|
|
|
|
|
|
If no valid path is found, null is returned and errno is set to
|
|
|
|
ENOTDIR if at least one such path was found, but it did not point
|
|
|
|
to a directory, EROTTEN if a arotten symbolic link was found, or
|
|
|
|
ENOENT if no file of the specified name was found. If both a rotten
|
|
|
|
symlink and a file are found, it is undefined which error status
|
|
|
|
will be returned.
|
|
|
|
|
2006-10-19 19:50:23 +08:00
|
|
|
\param in The name of the directory.
|
|
|
|
\param context the halloc context to use for memory allocations
|
|
|
|
\return 0 if the command can not be found, the path of the command otherwise.
|
|
|
|
*/
|
|
|
|
wchar_t *path_get_cdpath( void *context, wchar_t *in );
|
|
|
|
|
2008-01-14 00:47:47 +08:00
|
|
|
/**
|
|
|
|
Remove doulbe slashes and trailing slashes from a path,
|
|
|
|
e.g. transform foo//bar/ into foo/bar.
|
|
|
|
|
|
|
|
The returned string is allocated using the specified halloc
|
|
|
|
context.
|
|
|
|
*/
|
2007-05-11 03:11:28 +08:00
|
|
|
wchar_t *path_make_canonical( void *context, const wchar_t *path );
|
|
|
|
|
|
|
|
|
2006-10-19 19:50:23 +08:00
|
|
|
#endif
|