A class to hide path separator difference across platforms and assist in managing file system path names. More...
#include <sg_path.hxx>
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. |
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.
SGPath::SGPath | ( | const string & | p | ) |
Construct a path based on the starting path provided.
p | initial path |
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.
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.
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.
)
Definition at line 154 of file sg_path.cxx.
const char* SGPath::c_str | ( | ) | [inline] |
Get the path string.
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.
p | additional path suffix |
Definition at line 122 of file sg_path.cxx.
int SGPath::create_dir | ( | mode_t | mode | ) |
Create the designated directory.
Definition at line 191 of file sg_path.cxx.
string SGPath::dir | ( | ) | const |
Get the directory part of the path.
Definition at line 144 of file sg_path.cxx.
bool SGPath::exists | ( | ) | const |
Determine if file exists by attempting to fopen it.
Definition at line 175 of file sg_path.cxx.
string SGPath::extension | ( | ) | const |
Get the extension part of the path (everything after the final ".").
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).
Definition at line 133 of file sg_path.cxx.
void SGPath::set | ( | const string & | p | ) |
string SGPath::str | ( | ) | const [inline] |