SGPath Class Reference

A class to hide path separator difference across platforms and assist in managing file system path names. More...

#include <sg_path.hxx>

List of all members.

Public Member Functions

 SGPath ()
 Default constructor.
 SGPath (const string &p)
 Construct a path based on the starting path provided.
 ~SGPath ()
 Destructor.
void set (const string &p)
 Set path to a new value.
void append (const string &p)
 Append another piece to the existing path.
void add (const string &p)
 Append a new piece to the existing path.
void concat (const string &p)
 Concatenate a string to the end of the path without inserting a path separator.
string file () const
 Get the file part of the path (everything after the last path sep).
string dir () const
 Get the directory part of the path.
string base () const
 Get the base part of the path (everything but the extension.
string extension () const
 Get the extension part of the path (everything after the final ".").
string str () const
 Get the path string.
const char * c_str ()
 Get the path string.
bool exists () const
 Determine if file exists by attempting to fopen it.
int create_dir (mode_t mode)
 Create the designated directory.

Detailed Description

A class to hide path separator difference across platforms and assist in managing file system path names.

Paths can be input in any platform format and will be converted automatically to the proper format.

Definition at line 52 of file sg_path.hxx.


Constructor & Destructor Documentation

SGPath::SGPath ( const string &  p  ) 

Construct a path based on the starting path provided.

Parameters:
p initial path

Member Function Documentation

void SGPath::add ( const string &  p  ) 

Append a new piece to the existing path.

Inserts a search path separator to the existing path and the new patch component.

Parameters:
p additional path component

Definition at line 115 of file sg_path.cxx.

void SGPath::append ( const string &  p  ) 

Append another piece to the existing path.

Inserts a path separator between the existing component and the new component.

Parameters:
p additional path component

Definition at line 102 of file sg_path.cxx.

string SGPath::base (  )  const

Get the base part of the path (everything but the extension.

)

Returns:
the base string

Definition at line 154 of file sg_path.cxx.

const char* SGPath::c_str (  )  [inline]

Get the path string.

Returns:
path in "C" string (ptr to char array) form.

Definition at line 132 of file sg_path.hxx.

void SGPath::concat ( const string &  p  ) 

Concatenate a string to the end of the path without inserting a path separator.

Parameters:
p additional path suffix

Definition at line 122 of file sg_path.cxx.

int SGPath::create_dir ( mode_t  mode  ) 

Create the designated directory.

Returns:
0 on success, or <0 on failure.

Definition at line 191 of file sg_path.cxx.

string SGPath::dir (  )  const

Get the directory part of the path.

Returns:
directory string

Definition at line 144 of file sg_path.cxx.

bool SGPath::exists (  )  const

Determine if file exists by attempting to fopen it.

Returns:
true if file exists, otherwise returns false.

Definition at line 175 of file sg_path.cxx.

string SGPath::extension (  )  const

Get the extension part of the path (everything after the final ".").

Returns:
the extension string

Definition at line 166 of file sg_path.cxx.

string SGPath::file (  )  const

Get the file part of the path (everything after the last path sep).

Returns:
file string

Definition at line 133 of file sg_path.cxx.

void SGPath::set ( const string &  p  ) 

Set path to a new value.

Parameters:
p new path

Definition at line 95 of file sg_path.cxx.

string SGPath::str (  )  const [inline]

Get the path string.

Returns:
path string

Definition at line 126 of file sg_path.hxx.


The documentation for this class was generated from the following files:

Generated on 23 Feb 2010 for SimGear by  doxygen 1.6.1