OpenMPI  0.1.1
basename.h File Reference

Returns an OS-independant basename() of a given filename. More...

#include "opal_config.h"

Go to the source code of this file.

Functions

BEGIN_C_DECLS OPAL_DECLSPEC char * opal_basename (const char *filename) __opal_attribute_malloc__ __opal_attribute_warn_unused_result__
 Return the basename of a filename. More...
 
OPAL_DECLSPEC char * opal_dirname (const char *filename) __opal_attribute_malloc__ __opal_attribute_warn_unused_result__
 Return the dirname of a filename. More...
 

Detailed Description

Returns an OS-independant basename() of a given filename.

Function Documentation

BEGIN_C_DECLS OPAL_DECLSPEC char* opal_basename ( const char *  filename)

Return the basename of a filename.

Parameters
filenameThe filename to examine
Returns
A string containing the basename, or NULL if there is an error

The contents of the 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: returns "baz"

D:foo.txt returns "foo.txt"

E:.c returns "yow.c"

F: returns "F:"

G:\ returns "G:"

The caller is responsible for freeing the returned string.

Referenced by orte_plm_submit_launch().

OPAL_DECLSPEC char* opal_dirname ( const char *  filename)

Return the dirname of a filename.

Parameters
filenameThe filename to examine
Returns
A string containing the dirname, or NULL if there is an error

The contents of the 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: returns "C:\foo\bar"

D:foo.txt returns "D:"

E:.c returns "E:"

F: returns ""

G:\ returns ""

The caller is responsible for freeing the returned string.

References opal_make_filename_os_friendly.

Referenced by orte_iof_base_open(), and orte_session_dir().