On windows make sure we add the initial path separator only if we are
creating a relative path. Use BEGIN_C_DECLS and END_C_DECLS on some header files. This commit was SVN r15254.
Этот коммит содержится в:
родитель
951e4929b9
Коммит
003d1b8665
@ -25,85 +25,82 @@
|
||||
#ifndef OPAL_BASENAME_H
|
||||
#define OPAL_BASENAME_H
|
||||
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
/**
|
||||
* Return the basename of a filename.
|
||||
*
|
||||
* @param filename The filename to examine
|
||||
*
|
||||
* @returns A string containing the basename, or NULL if there is an error
|
||||
*
|
||||
* The contents of the \em filename parameter are unchanged. This
|
||||
* function returns a new string containing the basename of the
|
||||
* filename (which must be eventually freed by the caller), or
|
||||
* NULL if there is an error. Trailing "/" characters in the
|
||||
* filename do not count, unless it is in the only part of the
|
||||
* filename (e.g., "/" or "C:\").
|
||||
*
|
||||
* This function will do the Right Things on POSIX and
|
||||
* Windows-based operating systems. For example:
|
||||
*
|
||||
* foo.txt returns "foo.txt"
|
||||
*
|
||||
* /foo/bar/baz returns "baz"
|
||||
*
|
||||
* /yow.c returns "yow.c"
|
||||
*
|
||||
* / returns "/"
|
||||
*
|
||||
* C:\foo\bar\baz returns "baz"
|
||||
*
|
||||
* D:foo.txt returns "foo.txt"
|
||||
*
|
||||
* E:\yow.c returns "yow.c"
|
||||
*
|
||||
* F: returns "F:"
|
||||
*
|
||||
* G:\ returns "G:"
|
||||
*/
|
||||
OPAL_DECLSPEC char *opal_basename(const char* filename);
|
||||
BEGIN_C_DECLS
|
||||
|
||||
/**
|
||||
* Return the dirname of a filename.
|
||||
*
|
||||
* @param filename The filename to examine
|
||||
*
|
||||
* @returns A string containing the dirname, or NULL if there is an error
|
||||
*
|
||||
* The contents of the \em filename parameter are unchanged. This
|
||||
* function returns a new string containing the dirname of the
|
||||
* filename (which must be eventually freed by the caller), or
|
||||
* NULL if there is an error. Trailing "/" characters in the
|
||||
* filename do not count, unless it is in the only part of the
|
||||
* filename (e.g., "/" or "C:\").
|
||||
*
|
||||
* This function will do the Right Things on POSIX and
|
||||
* Windows-based operating systems. For example:
|
||||
*
|
||||
* foo.txt returns "foo.txt"
|
||||
*
|
||||
* /foo/bar/baz returns "/foo/bar"
|
||||
*
|
||||
* /yow.c returns "/"
|
||||
*
|
||||
* / returns ""
|
||||
*
|
||||
* C:\foo\bar\baz returns "C:\foo\bar"
|
||||
*
|
||||
* D:foo.txt returns "D:"
|
||||
*
|
||||
* E:\yow.c returns "E:"
|
||||
*
|
||||
* F: returns ""
|
||||
*
|
||||
* G:\ returns ""
|
||||
*/
|
||||
OPAL_DECLSPEC char *opal_dirname(const char* filename);
|
||||
/**
|
||||
* Return the basename of a filename.
|
||||
*
|
||||
* @param filename The filename to examine
|
||||
*
|
||||
* @returns A string containing the basename, or NULL if there is an error
|
||||
*
|
||||
* The contents of the \em filename parameter are unchanged. This
|
||||
* function returns a new string containing the basename of the
|
||||
* filename (which must be eventually freed by the caller), or
|
||||
* NULL if there is an error. Trailing "/" characters in the
|
||||
* filename do not count, unless it is in the only part of the
|
||||
* filename (e.g., "/" or "C:\").
|
||||
*
|
||||
* This function will do the Right Things on POSIX and
|
||||
* Windows-based operating systems. For example:
|
||||
*
|
||||
* foo.txt returns "foo.txt"
|
||||
*
|
||||
* /foo/bar/baz returns "baz"
|
||||
*
|
||||
* /yow.c returns "yow.c"
|
||||
*
|
||||
* / returns "/"
|
||||
*
|
||||
* C:\foo\bar\baz returns "baz"
|
||||
*
|
||||
* D:foo.txt returns "foo.txt"
|
||||
*
|
||||
* E:\yow.c returns "yow.c"
|
||||
*
|
||||
* F: returns "F:"
|
||||
*
|
||||
* G:\ returns "G:"
|
||||
*/
|
||||
OPAL_DECLSPEC char *opal_basename(const char* filename);
|
||||
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* Return the dirname of a filename.
|
||||
*
|
||||
* @param filename The filename to examine
|
||||
*
|
||||
* @returns A string containing the dirname, or NULL if there is an error
|
||||
*
|
||||
* The contents of the \em filename parameter are unchanged. This
|
||||
* function returns a new string containing the dirname of the
|
||||
* filename (which must be eventually freed by the caller), or
|
||||
* NULL if there is an error. Trailing "/" characters in the
|
||||
* filename do not count, unless it is in the only part of the
|
||||
* filename (e.g., "/" or "C:\").
|
||||
*
|
||||
* This function will do the Right Things on POSIX and
|
||||
* Windows-based operating systems. For example:
|
||||
*
|
||||
* foo.txt returns "foo.txt"
|
||||
*
|
||||
* /foo/bar/baz returns "/foo/bar"
|
||||
*
|
||||
* /yow.c returns "/"
|
||||
*
|
||||
* / returns ""
|
||||
*
|
||||
* C:\foo\bar\baz returns "C:\foo\bar"
|
||||
*
|
||||
* D:foo.txt returns "D:"
|
||||
*
|
||||
* E:\yow.c returns "E:"
|
||||
*
|
||||
* F: returns ""
|
||||
*
|
||||
* G:\ returns ""
|
||||
*/
|
||||
OPAL_DECLSPEC char *opal_dirname(const char* filename);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif /* OPAL_BASENAME_H */
|
||||
|
@ -52,9 +52,7 @@
|
||||
|
||||
#include "opal_config.h"
|
||||
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
BEGIN_C_DECLS
|
||||
|
||||
/**
|
||||
* Convert a size_t to an int.
|
||||
@ -76,8 +74,6 @@ extern "C" {
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_size2int(size_t in, int *out, bool want_check) __opal_attribute_nonnull__(2);
|
||||
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
END_C_DECLS
|
||||
|
||||
#endif
|
||||
|
@ -41,17 +41,11 @@
|
||||
#define OPAL_OS_DIRPATH_CREATE_H
|
||||
|
||||
#include "opal_config.h"
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
BEGIN_C_DECLS
|
||||
|
||||
/**
|
||||
* @param path A pointer to a string that contains the path name to be built.
|
||||
@ -119,8 +113,6 @@ OPAL_DECLSPEC int opal_os_dirpath_destroy(const char *path,
|
||||
bool recursive,
|
||||
opal_os_dirpath_destroy_callback_fn_t cbfunc);
|
||||
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
END_C_DECLS
|
||||
|
||||
#endif
|
||||
|
@ -47,9 +47,10 @@ char *opal_os_path(bool relative, ...)
|
||||
|
||||
num_elements = 0;
|
||||
total_length = 0;
|
||||
while (NULL != (element=va_arg(ap, char*))) {
|
||||
num_elements++;
|
||||
total_length = total_length + strlen(element);
|
||||
while (NULL != (element = va_arg(ap, char*))) {
|
||||
num_elements++;
|
||||
total_length = total_length + strlen(element);
|
||||
if( path_sep[0] != element[0] ) total_length++;
|
||||
}
|
||||
|
||||
if (0 == num_elements) { /* must be looking for a simple answer */
|
||||
@ -58,8 +59,7 @@ char *opal_os_path(bool relative, ...)
|
||||
if (relative) {
|
||||
strcpy(path, ".");
|
||||
strcat(path, path_sep);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
#ifndef __WINDOWS__
|
||||
strcpy(path, path_sep);
|
||||
#endif
|
||||
@ -89,12 +89,13 @@ char *opal_os_path(bool relative, ...)
|
||||
}
|
||||
|
||||
/* Windows does not require to have the initial separator. */
|
||||
if( NULL != (element=va_arg(ap1, char*)) ) {
|
||||
#ifndef __WINDOWS__
|
||||
if( NULL != (element = va_arg(ap1, char*)) ) {
|
||||
if (path_sep[0] != element[0]) {
|
||||
strcat(path, path_sep);
|
||||
}
|
||||
#ifdef __WINDOWS__
|
||||
if( relative )
|
||||
#endif /* __WINDOWS__ */
|
||||
strcat(path, path_sep);
|
||||
}
|
||||
strcat(path, element);
|
||||
}
|
||||
while (NULL != (element=va_arg(ap1, char*))) {
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user