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 - http://www.flightgear.org/~curt
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>
36 #include <simgear/math/sg_types.hxx>
42 * A class to hide path separator difference across platforms and assist
43 * in managing file system path names.
45 * Paths can be input in any platform format and will be converted
46 * automatically to the proper format.
57 /** Default constructor */
61 * Construct a path based on the starting path provided.
62 * @param p initial path
64 SGPath( const string& p );
70 * Set path to a new value
73 void set( const string& p );
74 SGPath& operator= ( const char* p ) { this->set(p); return *this; }
77 * Append another piece to the existing path. Inserts a path
78 * separator between the existing component and the new component.
79 * @param p additional path component */
80 void append( const string& p );
83 * Append a new piece to the existing path. Inserts a search path
84 * separator to the existing path and the new patch component.
85 * @param p additional path component */
86 void add( const string& p );
89 * Concatenate a string to the end of the path without inserting a
91 * @param p addtional path suffix
93 void concat( const string& p );
96 * Get the file part of the path (everything after the last path sep)
102 * Get the directory part of the path.
103 * @return directory string
108 * Get the base part of the path (everything but the extension.)
109 * @return the base string
114 * Get the extention part of the path (everything after the final ".")
115 * @return the extention string
117 string extension() const;
119 /** Get the path string
120 * @return path string
122 string str() const { return path; }
124 /** Get the path string
125 * @return path in "C" string (ptr to char array) form.
127 const char* c_str() { return path.c_str(); }
130 * Determine if file exists by attempting to fopen it.
131 * @return true if file exists, otherwise returns false.
143 * Split a directory search path into a vector of individual paths
145 string_list sgPathSplit( const string &search_path );
148 #endif // _SG_PATH_HXX