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 program is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU General Public License as
11 // published by the Free Software Foundation; either version 2 of the
12 // License, or (at your option) any later version.
14 // This program is distributed in the hope that it will be useful, but
15 // WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // General Public License for more details.
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the Free Software
21 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 // If Unix, replace all ":" with "/". If MacOS, replace all "/" with
30 // ":" it should go without saying that neither of these characters
31 // should be used in file or directory names. In windoze, allow the
32 // second character to be a ":" for things like c:\foo\bar
34 static string fix_path( const string path ) {
37 for ( int i = 0; i < (int)path.size(); ++i ) {
39 // for windoze, don't replace the ":" for the second character
44 if ( result[i] == FG_BAD_PATH_SEP ) {
45 result[i] = FG_PATH_SEP;
53 // default constructor
59 // create a path based on "path"
60 FGPath::FGPath( const string p ) {
71 void FGPath::set( const string p ) {
76 // append another piece to the existing path
77 void FGPath::append( const string p ) {
78 string part = fix_path( p );
80 if ( path.size() == 0 ) {
83 if ( part[0] != FG_PATH_SEP ) {
91 // concatenate a string to the end of the path without inserting a
93 void FGPath::concat( const string p ) {
94 string part = fix_path( p );
96 if ( path.size() == 0 ) {