2 // fgpath.cxx -- routines to abstract out path separator differences
3 // between MacOS and the rest of the world
5 // Written by Curtis L. Olson, started April 1999.
7 // Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Library General Public
11 // License as published by the Free Software Foundation; either
12 // version 2 of the License, or (at your option) any later version.
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Library General Public License for more details.
19 // You should have received a copy of the GNU Library General Public
20 // License along with this library; if not, write to the
21 // Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 // Boston, MA 02111-1307, USA.
30 // If Unix, replace all ":" with "/". If MacOS, replace all "/" with
31 // ":" it should go without saying that neither of these characters
32 // should be used in file or directory names. In windoze, allow the
33 // second character to be a ":" for things like c:\foo\bar
35 static string fix_path( const string path ) {
38 for ( int i = 0; i < (int)path.size(); ++i ) {
40 // for windoze, don't replace the ":" for the second character
45 if ( result[i] == FG_BAD_PATH_SEP ) {
46 result[i] = FG_PATH_SEP;
54 // default constructor
60 // create a path based on "path"
61 FGPath::FGPath( const string p ) {
72 void FGPath::set( const string p ) {
77 // append another piece to the existing path
78 void FGPath::append( const string p ) {
79 string part = fix_path( p );
81 if ( path.size() == 0 ) {
84 if ( part[0] != FG_PATH_SEP ) {
92 // concatenate a string to the end of the path without inserting a
94 void FGPath::concat( const string p ) {
95 string part = fix_path( p );
97 if ( path.size() == 0 ) {