]> git.mxchange.org Git - simgear.git/blob - simgear/misc/fgpath.hxx
From David Megginson:
[simgear.git] / simgear / misc / fgpath.hxx
1 //
2 // fgpath.hxx -- routines to abstract out path separator differences
3 //               between MacOS and the rest of the world
4 //
5 // Written by Curtis L. Olson, started April 1999.
6 //
7 // Copyright (C) 1999  Curtis L. Olson - curt@flightgear.org
8 //
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.
13 //
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.
18 //
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.
23 //
24 // $Id$
25
26
27 #ifndef _FGPATH_HXX
28 #define _FGPATH_HXX
29
30
31 #ifdef HAVE_CONFIG_H
32 #  include <config.h>
33 #endif
34
35 #include <simgear/compiler.h>
36
37 #include STL_STRING
38
39 FG_USING_STD(string);
40
41
42 #ifdef macintosh
43 #  define FG_PATH_SEP ':'
44 #  define FG_BAD_PATH_SEP '/'
45 #else
46 #  define FG_PATH_SEP '/'
47 #  define FG_BAD_PATH_SEP ':'
48 #endif
49
50
51 class FGPath {
52
53 private:
54
55     string path;
56
57 public:
58
59     // default constructor
60     FGPath();
61
62     // create a path based on "path"
63     FGPath( const string p );
64
65     // destructor
66     ~FGPath();
67
68     // set path
69     void set( const string p );
70
71     // append another piece to the existing path
72     void append( const string p );
73
74     // concatenate a string to the end of the path without inserting a
75     // path separator
76     void concat( const string p );
77
78     // get the directory part of the path
79     string dir();
80   
81     // get the path string
82     inline string str() const { return path; }
83     inline const char *c_str() { return path.c_str(); }
84 };
85
86
87 #endif // _FGPATH_HXX
88
89