2004-01-09 08:03:27 +00:00
|
|
|
/*
|
2005-11-05 19:57:48 +00:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2004-11-28 20:09:25 +00:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 12:43:37 +00:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2004-11-22 01:38:40 +00:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-01-09 08:03:27 +00:00
|
|
|
* $HEADER$
|
2005-02-09 17:13:54 +00:00
|
|
|
*
|
|
|
|
* @file
|
2004-01-09 08:03:27 +00:00
|
|
|
*/
|
|
|
|
|
2005-07-04 01:59:52 +00:00
|
|
|
#ifndef OPAL_PATH_H
|
|
|
|
#define OPAL_PATH_H
|
2004-01-09 08:03:27 +00:00
|
|
|
|
2006-02-12 01:33:29 +00:00
|
|
|
#include "opal_config.h"
|
2005-02-09 17:13:54 +00:00
|
|
|
|
2004-10-20 22:31:03 +00:00
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
2004-01-12 02:07:42 +00:00
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2005-02-09 17:13:54 +00:00
|
|
|
/**
|
|
|
|
* Locates a file with certain permissions
|
|
|
|
*
|
|
|
|
* @param fname File name
|
|
|
|
* @param pathv Array of search directories
|
2005-10-05 03:02:11 +00:00
|
|
|
* @param mode Permissions which must be satisfied (see access(2))
|
2005-02-09 17:13:54 +00:00
|
|
|
* @param envv Pointer to string containing environment
|
|
|
|
*
|
|
|
|
* @retval Full pathname of located file Success
|
|
|
|
* @retval NULL Failure
|
|
|
|
*
|
|
|
|
* Environment variables can appear in the form $variable at the
|
|
|
|
* start of a prefix path and will be replaced by the environment
|
|
|
|
* value if it is defined; otherwise the whole prefix is ignored.
|
|
|
|
* Environment variables must be followed by a path delimiter or
|
|
|
|
* end-of-string.
|
2005-10-05 03:02:11 +00:00
|
|
|
*
|
|
|
|
* The caller is responsible for freeing the returned string.
|
2005-02-09 17:13:54 +00:00
|
|
|
*/
|
2006-08-20 15:54:04 +00:00
|
|
|
OPAL_DECLSPEC char *opal_path_find(char *fname, char **pathv, int mode,
|
2005-02-09 17:13:54 +00:00
|
|
|
char **envv);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Locates a file with certain permissions from a list of search
|
|
|
|
* paths
|
|
|
|
*
|
|
|
|
* @param fname File name
|
2005-10-05 03:02:11 +00:00
|
|
|
* @param mode Target permissions which must be satisfied (see access(2))
|
2005-02-09 17:13:54 +00:00
|
|
|
* @param envv Pointer to environment list
|
|
|
|
* @param wrkdir Working directory
|
|
|
|
*
|
|
|
|
* @retval Full pathname of located file Success
|
|
|
|
* @retval NULL Failure
|
|
|
|
*
|
|
|
|
* Locates a file with certain permissions from the list of paths
|
|
|
|
* given by the $PATH environment variable. Replaces "." in the
|
|
|
|
* path with the working dir.
|
2005-10-05 03:02:11 +00:00
|
|
|
*
|
|
|
|
* The caller is responsible for freeing the returned string.
|
2005-02-09 17:13:54 +00:00
|
|
|
*/
|
2006-08-20 15:54:04 +00:00
|
|
|
OPAL_DECLSPEC char *opal_path_findv(char *fname, int mode,
|
2005-02-09 17:13:54 +00:00
|
|
|
char **envv, char *wrkdir);
|
2007-01-25 00:17:02 +00:00
|
|
|
/**
|
|
|
|
* 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 );
|
2004-01-09 08:03:27 +00:00
|
|
|
|
2007-03-01 13:39:20 +00:00
|
|
|
/**
|
|
|
|
* Forms a complete pathname and checks it for existance and
|
|
|
|
* permissions
|
|
|
|
*
|
|
|
|
* @param fname File name
|
|
|
|
* @param path Path prefix, if NULL then fname is an absolute path
|
|
|
|
* @param mode Target permissions which must be satisfied (see access(2))
|
|
|
|
*
|
|
|
|
* @retval NULL Failure
|
|
|
|
* @retval Full pathname of the located file on Success
|
|
|
|
*/
|
|
|
|
OPAL_DECLSPEC char *opal_path_access(char *fname, char *path, int mode);
|
|
|
|
|
2004-10-20 22:31:03 +00:00
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
2004-01-12 02:07:42 +00:00
|
|
|
}
|
|
|
|
#endif
|
2005-07-04 01:59:52 +00:00
|
|
|
#endif /* OPAL_PATH_H */
|