1
1

Export opal_path_is_absolute which correctly compute if a path is

absolute or not.

This commit was SVN r13292.
Этот коммит содержится в:
George Bosilca 2007-01-25 00:17:02 +00:00
родитель a5b13f824d
Коммит b6307807d8
2 изменённых файлов: 29 добавлений и 2 удалений

Просмотреть файл

@ -32,6 +32,21 @@ static void path_env_load(char *path, int *pargc, char ***pargv);
static char *path_access(char *fname, char *path, int mode); static char *path_access(char *fname, char *path, int mode);
static char *list_env_get(char *var, char **list); static char *list_env_get(char *var, char **list);
bool opal_path_is_absolute( const char *path )
{
#if defined(__WINDOWS__)
/* On Windows an absolute path always start with [a-z]:\ */
if( ':' == path[1] ) {
return true;
}
#else
if( OPAL_PATH_SEP[0] == *path ) {
return true;
}
#endif /* defined(__WINDOWS__) */
return false;
}
/** /**
* Locates a file with certain permissions * Locates a file with certain permissions
*/ */
@ -44,8 +59,7 @@ char *opal_path_find(char *fname, char **pathv, int mode, char **envv)
int i; int i;
/* If absolute path is given, return it without searching. */ /* If absolute path is given, return it without searching. */
if( opal_path_is_absolute(fname) ) {
if (OPAL_PATH_SEP[0] == *fname) {
return path_access(fname, "", mode); return path_access(fname, "", mode);
} }

Просмотреть файл

@ -69,6 +69,19 @@ extern "C" {
*/ */
OPAL_DECLSPEC char *opal_path_findv(char *fname, int mode, OPAL_DECLSPEC char *opal_path_findv(char *fname, int mode,
char **envv, char *wrkdir); char **envv, char *wrkdir);
/**
* Detect if the requested path is absolute or relative.
*
* @param path File name
*
* @retval true if the path is absolute
* @retval false otherwise
*
* Detect if a path is absolute or relative. Handle Windows
* with special care as an absolute path on Windows starts
* with [A-Za-z]: instead of the usual / on UNIX.
*/
OPAL_DECLSPEC bool opal_path_is_absolute( const char *path );
#if defined(c_plusplus) || defined(__cplusplus) #if defined(c_plusplus) || defined(__cplusplus)
} }