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.
SGPathoperator= (const char *p)
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 extention 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.
void 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::set ( const string &  p  ) 

Set path to a new value.

Parameters:
p new path

Definition at line 100 of file sg_path.cxx.

Referenced by SGNewCloud::loadTextures(), operator=(), SGCloudLayer::rebuild(), and SGTime::updateLocal().

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 107 of file sg_path.cxx.

Referenced by add(), SGSun::build(), SGMoon::build(), SGStarData::load(), SGSoundSample::load_file(), SGNewCloud::loadTextures(), SGCloudLayer::rebuild(), SGMaterialAnimation::SGMaterialAnimation(), SGSoundSample::SGSoundSample(), PropsVisitor::startElement(), SGMaterialAnimation::update(), and SGTime::updateLocal().

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 120 of file sg_path.cxx.

References append().

void SGPath::concat ( const string &  p  ) 

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

Parameters:
p addtional path suffix

Definition at line 127 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 138 of file sg_path.cxx.

string SGPath::dir (  )  const

Get the directory part of the path.

Returns:
directory string

Definition at line 149 of file sg_path.cxx.

Referenced by create_dir().

string SGPath::base (  )  const

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

)

Returns:
the base string

Definition at line 159 of file sg_path.cxx.

string SGPath::extension (  )  const

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

Returns:
the extention string

Definition at line 171 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.

Referenced by SGBucket::gen_base_path(), SGStarData::load(), SGSoundSample::load_file(), SGNewCloud::loadTextures(), SGCloudLayer::rebuild(), SGSoundSample::SGSoundSample(), PropsVisitor::startElement(), SGTime::updateLocal(), SGBinObject::write_ascii(), and SGBinObject::write_bin().

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.

Referenced by SGSun::build(), SGMoon::build(), SGSoundSample::load_file(), SGSoundSample::SGSoundSample(), SGTime::updateLocal(), SGBinObject::write_ascii(), and SGBinObject::write_bin().

bool SGPath::exists (  )  const

Determine if file exists by attempting to fopen it.

Returns:
true if file exists, otherwise returns false.

Definition at line 180 of file sg_path.cxx.


The documentation for this class was generated from the following files:
Generated on Mon Dec 17 09:30:57 2007 for SimGear by  doxygen 1.5.1