MrSID Decode SDK for Raster Reference Manual  9.5.1.4427
lt_fileSpec.h
Go to the documentation of this file.
1 /* $Id$ */
2 /* //////////////////////////////////////////////////////////////////////////
3 // //
4 // This code is Copyright (c) 2004 LizardTech, Inc, 1008 Western Avenue, //
5 // Suite 200, Seattle, WA 98104. Unauthorized use or distribution //
6 // prohibited. Access to and use of this code is permitted only under //
7 // license from LizardTech, Inc. Portions of the code are protected by //
8 // US and foreign patents and other filings. All Rights Reserved. //
9 // //
11 /* PUBLIC */
12 
13 #ifndef LT_FILESPEC_H
14 #define LT_FILESPEC_H
15 
16 // lt_lib_base
17 #include "lt_base.h"
18 #include "lt_system.h"
19 
20 LT_BEGIN_NAMESPACE(LizardTech)
24 #ifdef LT_OS_WIN
25 #define LT_UTIL_MAX_PATH _MAX_PATH
26 #else
27 #define LT_UTIL_MAX_PATH 2048
28 #endif
29 
34 {
35 public:
36  enum
37  {
38  fSlash = '/',
39  bSlash = '\\',
40 #ifdef LT_OS_WIN
41  platformSlash = '\\'
42 #else
44 #endif
45  };
46 
47 
48 public:
52  LTFileSpec(void);
53 
57  ~LTFileSpec(void);
58 
59 #ifndef SWIG
60 
69  LTFileSpec(const char *p1,
70  EncodingType encoding = NATIVE);
71  LTFileSpec(const char *p1, const char *p2,
72  EncodingType encoding = NATIVE);
73  LTFileSpec(const char *p1, const char *p2, const char *p3,
74  EncodingType encoding = NATIVE);
75 #endif
76 
82  explicit LTFileSpec(const wchar_t *p1);
83  LTFileSpec(const wchar_t *p1, const wchar_t *p2);
84  LTFileSpec(const wchar_t *p1, const wchar_t *p2, const wchar_t *p3);
85 
86 #ifndef LT_OS_WIN
87 
91  explicit LTFileSpec(const lt_uint16 *path);
92  LTFileSpec(const lt_uint16 *p1, const lt_uint16 *p2);
93  LTFileSpec(const lt_uint16 *p1, const lt_uint16 *p2, const lt_uint16 *p3);
94 #endif
95 
96  LTFileSpec(const LTFileSpec &p1);
97  LTFileSpec(const LTFileSpec &p1, const LTFileSpec &p2);
98  LTFileSpec(const LTFileSpec &p1, const LTFileSpec &p2, const LTFileSpec &p3);
99 #ifndef SWIG
100  LTFileSpec(const LTFileSpec &p1, const char *p2,
101  EncodingType encoding);
102  LTFileSpec(const LTFileSpec &p1, const char *p2, const char *p3,
103  EncodingType encoding);
104  LTFileSpec(const LTFileSpec &p1, const LTFileSpec &p2, const char *p3,
105  EncodingType encoding);
106 #endif
107  LTFileSpec(const LTFileSpec &p1, const wchar_t *p2);
108  LTFileSpec(const LTFileSpec &p1, const wchar_t *p2, const wchar_t *p3);
109  LTFileSpec(const LTFileSpec &p1, const LTFileSpec &p2, const wchar_t *p3);
110 
111 #ifndef LT_OS_WIN
112  LTFileSpec(const LTFileSpec &p1, const lt_uint16 *p2);
113  LTFileSpec(const LTFileSpec &p1, const lt_uint16 *p2, const lt_uint16 *p3);
114  LTFileSpec(const LTFileSpec &p1, const LTFileSpec &p2, const lt_uint16 *p3);
115 #endif
116 
122  LTFileSpec& operator=(const LTFileSpec &that);
123 
127  bool operator!=(const LTFileSpec& fs) const;
128 
132  bool operator==(const LTFileSpec& fs) const;
133 
134  // is the fileSpec empty
135  bool empty(void) const;
136 
140  const char *utf8(void) const;
141 
148  const char *n_str(void) const;
149 
156  const wchar_t *w_str(void) const;
171  LTFileSpec dirname(void) const;
172 
187  const char *basename(void) const;
188 
197  const char* getSuffix() const;
198 
211  LTFileSpec replaceSuffix(const char* ext) const;
212 
223  LTFileSpec removeSuffix() const;
224 
228  bool absolute() const;
229 
230 protected:
231 
236  void init(const char *p1, const char *p2, const char *p3);
237 
238  size_t getPrefixLength(void) const;
239 private:
240  // using a utf8 string to hold the path because it is the easiest
241  // to play with (we can look for bSlashs and not have to worry
242  // about lead btyes.
243  char *m_path8;
244  mutable char *m_pathA; // this will be updated in n_str()
245  mutable wchar_t *m_pathW; // this will be updated in w_str()
246 
247 };
248 
249 LT_END_NAMESPACE(LizardTech)
250 
251 #endif // LT_FILESPEC_H

LizardTech