00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012
00013 #ifndef LT_FILESPEC_H
00014 #define LT_FILESPEC_H
00015
00016
00017 #include "lt_base.h"
00018 #include "lt_system.h"
00019
00020 LT_BEGIN_NAMESPACE(LizardTech)
00024 #ifdef LT_OS_WIN
00025 #define LT_UTIL_MAX_PATH _MAX_PATH
00026 #else
00027 #define LT_UTIL_MAX_PATH 2048
00028 #endif
00029
00033 class LTFileSpec
00034 {
00035 public:
00036 enum
00037 {
00038 fSlash = '/',
00039 bSlash = '\\',
00040 #ifdef LT_OS_WIN
00041 platformSlash = '\\'
00042 #else
00043 platformSlash = '/'
00044 #endif
00045 };
00046
00047
00048 public:
00052 LTFileSpec(void);
00053
00057 ~LTFileSpec(void);
00058
00059 #ifndef SWIG
00060
00068 enum EncodingType { NATIVE, UTF8 };
00069 LTFileSpec(const char *p1,
00070 EncodingType encoding = NATIVE);
00071 LTFileSpec(const char *p1, const char *p2,
00072 EncodingType encoding = NATIVE);
00073 LTFileSpec(const char *p1, const char *p2, const char *p3,
00074 EncodingType encoding = NATIVE);
00075 #endif
00076
00082 explicit LTFileSpec(const wchar_t *p1);
00083 LTFileSpec(const wchar_t *p1, const wchar_t *p2);
00084 LTFileSpec(const wchar_t *p1, const wchar_t *p2, const wchar_t *p3);
00085
00086 #ifndef LT_OS_WIN
00087
00091 explicit LTFileSpec(const lt_uint16 *path);
00092 LTFileSpec(const lt_uint16 *p1, const lt_uint16 *p2);
00093 LTFileSpec(const lt_uint16 *p1, const lt_uint16 *p2, const lt_uint16 *p3);
00094 #endif
00095
00096 LTFileSpec(const LTFileSpec &p1);
00097 LTFileSpec(const LTFileSpec &p1, const LTFileSpec &p2);
00098 LTFileSpec(const LTFileSpec &p1, const LTFileSpec &p2, const LTFileSpec &p3);
00099 #ifndef SWIG
00100 LTFileSpec(const LTFileSpec &p1, const char *p2,
00101 EncodingType encoding);
00102 LTFileSpec(const LTFileSpec &p1, const char *p2, const char *p3,
00103 EncodingType encoding);
00104 LTFileSpec(const LTFileSpec &p1, const LTFileSpec &p2, const char *p3,
00105 EncodingType encoding);
00106 #endif
00107 LTFileSpec(const LTFileSpec &p1, const wchar_t *p2);
00108 LTFileSpec(const LTFileSpec &p1, const wchar_t *p2, const wchar_t *p3);
00109 LTFileSpec(const LTFileSpec &p1, const LTFileSpec &p2, const wchar_t *p3);
00110
00111 #ifndef LT_OS_WIN
00112 LTFileSpec(const LTFileSpec &p1, const lt_uint16 *p2);
00113 LTFileSpec(const LTFileSpec &p1, const lt_uint16 *p2, const lt_uint16 *p3);
00114 LTFileSpec(const LTFileSpec &p1, const LTFileSpec &p2, const lt_uint16 *p3);
00115 #endif
00116
00122 LTFileSpec& operator=(const LTFileSpec &that);
00123
00127 bool operator!=(const LTFileSpec& fs) const;
00128
00132 bool operator==(const LTFileSpec& fs) const;
00133
00134
00135 bool empty(void) const;
00136
00140 const char *utf8(void) const;
00141
00148 const char *n_str(void) const;
00149
00156 const wchar_t *w_str(void) const;
00171 LTFileSpec dirname(void) const;
00172
00187 const char *basename(void) const;
00188
00197 const char* getSuffix() const;
00198
00211 LTFileSpec replaceSuffix(const char* ext) const;
00212
00223 LTFileSpec removeSuffix() const;
00224
00228 bool absolute() const;
00229
00230 protected:
00231
00236 void init(const char *p1, const char *p2, const char *p3);
00237
00238 size_t getPrefixLength(void) const;
00239 private:
00240
00241
00242
00243 char *m_path8;
00244 mutable char *m_pathA;
00245 mutable wchar_t *m_pathW;
00246
00247 };
00248
00249 LT_END_NAMESPACE(LizardTech)
00250
00251 #endif // LT_FILESPEC_H