OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimFilename.h
Go to the documentation of this file.
1 //---
2 //
3 // License: MIT
4 //
5 // Author: Ken Melero
6 //
7 // Description: This class provides manipulation of filenames.
8 //
9 //---
10 // $Id$
11 
12 #ifndef ossimFilename_HEADER
13 #define ossimFilename_HEADER 1
14 
16 #include <ossim/base/ossimString.h>
17 
18 class ossimLocalTm;
19 
21 {
22 public:
24  {
25  OSSIM_READ_WRITE = 6,
26  OSSIM_READ = 4,
27  OSSIM_WRITE = 2,
28  OSSIM_EXE = 1, // The PC docs say that this is ignored
29  OSSIM_EXIST = 0
30  };
31  ossimFilename();
32  ossimFilename(const ossimFilename& src);
33  ossimFilename(const ossimString& src);
34  ossimFilename(const std::string& src);
35  ossimFilename(const char* src);
36  const ossimFilename& operator=(const ossimFilename& f);
37 
38  template <class Iter> ossimFilename(Iter s, Iter e);
39 
40  static const ossimFilename NIL;
41 
42  bool operator == (const ossimFilename& rhs)const;
43 
44  bool operator == (const ossimString& rhs)const;
45  bool operator == (const char* rhs)const;
46 
48 // friend std::ostream& operator<<(std::ostream& os,
49  // const ossimFilename& s);
50 
51  // void convertBackToForwardSlashes();
52  // void convertForwardToBackSlashes();
53 
54  bool setTimes(ossimLocalTm* accessTime,
55  ossimLocalTm* modTime,
56  ossimLocalTm* createTime)const;
57  bool getTimes(ossimLocalTm* accessTime,
58  ossimLocalTm* modTime,
59  ossimLocalTm* createTime)const;
66  ossim_int64 lastAccessed() const;
67 
68  bool touch()const;
69 
79  ossimFilename expand() const;
80 
81  // Methods to test ossimFilename for various states.
82  bool exists() const;
83  bool isFile() const;
84  bool isDir() const;
85  bool isReadable() const;
86  bool isUrl() const;
87  bool isWriteable() const;
88  bool isExecutable() const;
89 
90  ossim_int64 fileSize() const;
91 
92  // Methods to access parts of the ossimFilename.
93 
99  ossimString ext() const;
100 
104  ossimFilename path() const;
105 
109  ossimFilename drive() const;
110 
114  ossimFilename file() const;
115 
119  ossimFilename fileNoExtension() const;
120 
126  ossimFilename noExtension() const;
127 
157  ossimFilename& setExtension(const ossimString& e);
158 
166  ossimFilename& setDrive(const ossimString& d);
167  ossimFilename& setPath(const ossimString& p);
168  ossimFilename& setFile(const ossimString& f);
169 
170  void split(ossimString& drivePart,
171  ossimString& pathPart,
172  ossimString& filePart,
173  ossimString& extPart)const;
174 
175  void merge(const ossimString& drivePart,
176  const ossimString& pathPart,
177  const ossimString& filePart,
178  const ossimString& extPart);
185  ossimFilename dirCat(const ossimFilename& file) const;
186 
189  bool createDirectory(bool recurseFlag=true,
190  int perm=0775)const;
191 
200  static bool remove(const ossimFilename& pathname);
201 
212  static bool wildcardRemove(const ossimFilename& pathname);
213 
214  bool rename(const ossimFilename& destFile, bool overwriteDestinationFlag=true)const;
215 
216  bool remove()const;
217  bool wildcardRemove()const;
218 
229  bool copyFileTo(const ossimFilename& outputFile) const;
230 
238  bool isRelative() const;
239 
250  bool needsExpansion() const;
251 
253  char getPathSeparator() const;
254 
259  ossimFilename& appendTimestamp();
260 
264  ossimFilename& append(const ossimString& append_this_to_filename);
265 
269  std::string native() const;
270 
271 protected:
272 
276  void converPathSeparator();
277 
278  // void convertToNative();
279 
284  static const char OSSIM_NATIVE_PATH_SEPARATOR;
285  static const char OSSIM_FILENAME_PATH_SEPARATOR;
286 };
287 
288 // inline std::ostream& operator<<(std::ostream& os, const ossimFilename& f)
289 // {
290 // return os << f.string().c_str();
291 // }
292 
293 #endif
static const ossimFilename NIL
This was taken from Wx widgets for performing touch and access date stamps.
Definition: ossimFilename.h:40
void split(std::vector< ossimString > &result, const ossimString &separatorList, bool skipBlankFields=false) const
Splits this string into a vector of strings (fields) using the delimiter list specified.
friend OSSIM_DLL bool operator==(const char *lhs, const ossimString &rhs)
Definition: ossimString.h:955
const ossimString & append(const ossimString &s)
Definition: ossimString.h:831
const ossimString & operator=(const std::string &s)
Definition: ossimString.h:99
static const char OSSIM_NATIVE_PATH_SEPARATOR
static const char OSSIM_FILENAME_PATH_SEPARATOR
#define OSSIM_DLL
long long ossim_int64