3 * Routines to abstract out path separator differences between MacOS
4 * and the rest of the world.
7 // Written by Curtis L. Olson, started April 1999.
9 // Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
11 // This library is free software; you can redistribute it and/or
12 // modify it under the terms of the GNU Library General Public
13 // License as published by the Free Software Foundation; either
14 // version 2 of the License, or (at your option) any later version.
16 // This library is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 // Library General Public License for more details.
21 // You should have received a copy of the GNU Library General Public
22 // License along with this library; if not, write to the
23 // Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 // Boston, MA 02111-1307, USA.
33 #include <simgear/compiler.h>
41 # define SG_PATH_SEP ':'
42 # define SG_BAD_PATH_SEP '/'
44 # define SG_PATH_SEP '/'
45 # define SG_BAD_PATH_SEP ':'
50 * A class to hide path separator difference across platforms and assist
51 * in managing file system path names.
53 * Paths can be input in any platform format and will be converted
54 * automatically to the proper format.
65 /** Default constructor */
69 * Construct a path based on the starting path provided.
70 * @param p initial path
72 SGPath( const string& p );
78 * Set path to a new value
81 void set( const string& p );
82 SGPath& operator= ( const char* p ) { this->set(p); return *this; }
85 * Append another piece to the existing path. Inserts a path
86 * separator between the existing component and the new component.
87 * @param p additional path component */
88 void append( const string& p );
91 * Concatenate a string to the end of the path without inserting a
93 * @param p addtional path suffix
95 void concat( const string& p );
98 * Get the directory part of the path.
99 * @return directory string
104 * Return the filename part of the path.
105 * @return file name string
109 /** Get the path string
110 * @return path string
112 string str() const { return path; }
114 /** Get the path string
115 * @return path in "C" string (ptr to char array) form.
117 const char* c_str() { return path.c_str(); }
120 * Determine if file exists by attempting to fopen it.
121 * @return true if file exists, otherwise returns false.
132 #endif // _SG_PATH_HXX