OpenMPI 0.1.1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

os_path.h
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3 * University Research and Technology
4 * Corporation. All rights reserved.
5 * Copyright (c) 2004-2005 The University of Tennessee and The University
6 * of Tennessee Research Foundation. All rights
7 * reserved.
8 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9 * University of Stuttgart. All rights reserved.
10 * Copyright (c) 2004-2005 The Regents of the University of California.
11 * All rights reserved.
12 * $COPYRIGHT$
13 *
14 * Additional copyrights may follow
15 *
16 * $HEADER$
17 */
18
19 /** @file:
20 * Creates an operating system-acceptable path name.
21 *
22 * The opal_os_path() function takes a variable number of string arguments and
23 * concatenates them into a path name using the path separator character appropriate
24 * to the local operating system. NOTE: the string returned by this function has been
25 * malloc'd - thus, the user is responsible for free'ing the memory used by
26 * the string.
27 *
28 * CRITICAL NOTE: The input variable list MUST be terminated by a NULL value. Failure
29 * to do this will cause the program to suffer a catastrophic failure - usually a
30 * segmentation violation or bus error.
31 *
32 * The function calls orte_sys_info() to ensure that the path separator character
33 * has been identified. If that value cannot be identified for some reason,
34 * the function will return a NULL value. Likewise, specifying a path name that
35 * exceeds the maximum allowable path name length on the local system will result
36 * in the return of a NULL value.
37 *
38 *
39 */
40
41 #ifndef OPAL_OS_PATH_H
42 #define OPAL_OS_PATH_H
43
44 #include "opal_config.h"
45
46 #include <stdio.h>
47 #include <stdarg.h>
48
49 BEGIN_C_DECLS
50
51 /**
52 * @param relative A boolean that specifies if the path name is to be constructed
53 * relative to the current directory or as an absolute path. If no path
54 * elements are included in the function call, then the function returns
55 * "." for a relative path name and "<path separator char>" -
56 * the top of the directory tree - for an absolute path name.
57 * @param elem1,elem2,... A variable number of (char *)path_elements
58 * can be provided to the function, terminated by a NULL value. These
59 * elements will be concatenated, each separated by the path separator
60 * character, into a path name and returned.
61 * @retval path_name A pointer to a fully qualified path name composed of the
62 * provided path elements, separated by the path separator character
63 * appropriate to the local operating system. The path_name string has been malloc'd
64 * and therefore the user is responsible for free'ing the field.
65 */
66 OPAL_DECLSPEC char *opal_os_path(bool relative, ...) __opal_attribute_malloc__ __opal_attribute_sentinel__ __opal_attribute_warn_unused_result__;
67
68 /**
69 * Convert the path to be OS friendly. On UNIX this function will
70 * be empty, when on Windows it will convert all '/' to '\\' and
71 * eventually remove the '/cygdrive/' from the beginning of the
72 * path (if the configure was runned under Cygwin).
73 */
74 #if defined(__WINDOWS__)
75 static inline char* opal_make_filename_os_friendly( char* filename )
76 {
77 char* p = filename;
78 size_t length;
79
80 if( NULL == filename )
81 return NULL;
82
83 length = strlen(filename);
84 if( strncmp( filename, "/cygdrive/", 10 ) == 0 ) {
85 memmove( filename + 1, filename + 10, length - 10 );
86 filename[0] = filename[1];
87 filename[1] = ':';
88 filename[length - 10 + 1] = '\0';
89 }
90 for( ; *p != '\0'; p++ ) {
91 if( *p == '/' )
92 *p = '\\';
93 }
94 return filename;
95 }
96 #else
97 #define opal_make_filename_os_friendly(PATH) (PATH)
98 #endif /* defined(__WINDOWS__) */
99
100 END_C_DECLS
101
102 #endif /* OPAL_OS_PATH_H */
opal_make_filename_os_friendly
#define opal_make_filename_os_friendly(PATH)
Convert the path to be OS friendly.
Definition: os_path.h:97
opal_os_path
BEGIN_C_DECLS OPAL_DECLSPEC char * opal_os_path(bool relative,...) __opal_attribute_malloc__ __opal_attribute_sentinel__ __opal_attribute_warn_unused_result__
Definition: os_path.c:35