Export opal_path_is_absolute which correctly compute if a path is
absolute or not. This commit was SVN r13292.
Этот коммит содержится в:
родитель
a5b13f824d
Коммит
b6307807d8
@ -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 *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
|
||||
*/
|
||||
@ -44,8 +59,7 @@ char *opal_path_find(char *fname, char **pathv, int mode, char **envv)
|
||||
int i;
|
||||
|
||||
/* If absolute path is given, return it without searching. */
|
||||
|
||||
if (OPAL_PATH_SEP[0] == *fname) {
|
||||
if( opal_path_is_absolute(fname) ) {
|
||||
return path_access(fname, "", mode);
|
||||
}
|
||||
|
||||
|
@ -69,6 +69,19 @@ extern "C" {
|
||||
*/
|
||||
OPAL_DECLSPEC char *opal_path_findv(char *fname, int mode,
|
||||
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)
|
||||
}
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user