ROLAND  0.70
Amstrad Emulator based on Caprice Source rewritten in C++.
filename.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Fred Klaus *
3  * frednet@web.de *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 #ifndef FILENAME_H
21 #define FILENAME_H
22 
23 #include <string>
24 
25 using std::string;
26 
28 
39 class FileName : public string
40 {
41 
42 public:
43  FileName() : string("") {}
44  FileName(const string & filename) : string(filename) {}
45  ~FileName() {}
46 
48  bool operator<(const FileName & fn);
50  bool operator==(const FileName & fn);
51 
52  //FileName(const FileName & filename) : string(filename) {}
53  //const FileName & operator=(const FileName & filename) {*this=filename; return *this;}
54 
55  string qualified() const;
56  string base(bool ext=true) const;
57  string path() const;
58  string relpath() const;
59  string ext(bool dot=true) const;
60 
63  void set(const string & filename) {*this=filename;}
64  void setBase(const string & basename, bool ext=true);
65  void setExt(const string & extension);
66  void setPath(const string & path);
67 
68  bool isValid();
69  bool isRelative();
74  static void setCaseSensitiveCompare(bool csc) {mCaseSensitive = csc;}
75 
76 private:
77 #if defined(_WIN32) || defined(_WIN64)
78  static char delim() {return '\\';}
79  #define snprintf _snprintf
80  #define vsnprintf _vsnprintf
81  #define strcasecmp _stricmp
82  #define strncasecmp _strnicmp
83 #else
84  static char delim() {return '/';}
85 #endif // _WIN32 ||_WIN64
86 
87  static bool mCaseSensitive;
88 
89 };
90 
91 
92 #endif
FileName()
Definition: filename.h:43
string ext(bool dot=true) const
Definition: filename.cpp:70
void setExt(const string &extension)
Definition: filename.cpp:92
[std::string] extension for filenames
Definition: filename.h:39
void setPath(const string &path)
Definition: filename.cpp:105
FileName(const string &filename)
Definition: filename.h:44
static void setCaseSensitiveCompare(bool csc)
Definition: filename.h:74
string qualified() const
Definition: filename.cpp:44
static char delim()
Definition: filename.h:84
bool isValid()
bool isRelative()
bool operator==(const FileName &fn)
Definition: filename.cpp:36
~FileName()
Definition: filename.h:45
void setBase(const string &basename, bool ext=true)
Definition: filename.cpp:81
string path() const
Definition: filename.cpp:60
string relpath() const
Definition: filename.cpp:62
static bool mCaseSensitive
Definition: filename.h:87
bool operator<(const FileName &fn)
Definition: filename.cpp:28
string base(bool ext=true) const
Definition: filename.cpp:52