Line 11... |
Line 11... |
11 |
enum {CATFILE_NONE, CATFILE_READ, CATFILE_DECYPTED};
|
11 |
enum {CATFILE_NONE, CATFILE_READ, CATFILE_DECYPTED};
|
12 |
enum {CATREAD_JUSTCONTENTS, CATREAD_CAT, CATREAD_CATDECRYPT, CATREAD_DAT};
|
12 |
enum {CATREAD_JUSTCONTENTS, CATREAD_CAT, CATREAD_CATDECRYPT, CATREAD_DAT};
|
13 |
|
13 |
|
14 |
typedef struct SInCatFile {
|
14 |
typedef struct SInCatFile {
|
15 |
SInCatFile () { lSize = 0; sData = 0; lOffset = 0; bDelete = false; bDecrypted = false; }
|
15 |
SInCatFile () { lSize = 0; sData = 0; lOffset = 0; bDelete = false; bDecrypted = false; }
|
16 |
Utils::String sFile;
|
16 |
Utils::WString sFile;
|
17 |
size_t lSize;
|
17 |
size_t lSize;
|
18 |
unsigned char *sData;
|
18 |
unsigned char *sData;
|
19 |
size_t lOffset;
|
19 |
size_t lOffset;
|
20 |
bool bDelete;
|
20 |
bool bDelete;
|
21 |
bool bDecrypted;
|
21 |
bool bDecrypted;
|
Line 31... |
Line 31... |
31 |
FILETYPE_DEFLATE,
|
31 |
FILETYPE_DEFLATE,
|
32 |
FILETYPE_PCK,
|
32 |
FILETYPE_PCK,
|
33 |
};
|
33 |
};
|
34 |
|
34 |
|
35 |
public:
|
35 |
public:
|
36 |
static Utils::String PckChangeExtension(const Utils::String &f);
|
36 |
static Utils::WString PckChangeExtension(const Utils::WString &f);
|
37 |
static Utils::String RenameFileExtension(SInCatFile *f);
|
37 |
static Utils::WString RenameFileExtension(SInCatFile *f);
|
38 |
static bool IsAddonDir(const Utils::String &dir);
|
38 |
static bool IsAddonDir(const Utils::WString &dir);
|
39 |
static bool CheckPackedExtension(const Utils::String &sFilename);
|
39 |
static bool CheckPackedExtension(const Utils::WString &sFilename);
|
40 |
|
40 |
|
41 |
public:
|
41 |
public:
|
42 |
CCatFile ();
|
42 |
CCatFile ();
|
43 |
~CCatFile ();
|
43 |
~CCatFile ();
|
44 |
|
44 |
|
45 |
int open(const Utils::String &catfile, const Utils::String &addon, int readtype = CATREAD_CATDECRYPT, bool create = true);
|
45 |
int open(const Utils::WString &catfile, const Utils::WString &addon, int readtype = CATREAD_CATDECRYPT, bool create = true);
|
46 |
bool DecryptData ();
|
46 |
bool DecryptData ();
|
47 |
bool DecryptData ( unsigned char *data, size_t size );
|
47 |
bool DecryptData ( unsigned char *data, size_t size );
|
48 |
void DecryptDAT(unsigned char *buffer, size_t size);
|
48 |
void DecryptDAT(unsigned char *buffer, size_t size);
|
49 |
void DecryptDAT(SInCatFile *pFile);
|
49 |
void DecryptDAT(SInCatFile *pFile);
|
50 |
bool readFiles ();
|
50 |
bool readFiles ();
|
51 |
void LoadDatFile ();
|
51 |
void LoadDatFile ();
|
52 |
|
52 |
|
53 |
bool checkExtensionPck(const Utils::String &filename) const;
|
53 |
bool checkExtensionPck(const Utils::WString &filename) const;
|
54 |
|
54 |
|
55 |
unsigned char *readData(const Utils::String &filename, size_t *size);
|
55 |
unsigned char *readData(const Utils::WString &filename, size_t *size);
|
56 |
unsigned char *readData(SInCatFile *c, size_t *size);
|
56 |
unsigned char *readData(SInCatFile *c, size_t *size);
|
57 |
SInCatFile *findData(const Utils::String &filename) const;
|
57 |
SInCatFile *findData(const Utils::WString &filename) const;
|
58 |
bool readFileToData(const Utils::String &filename);
|
58 |
bool readFileToData(const Utils::WString &filename);
|
59 |
bool readFileToData(SInCatFile *c);
|
59 |
bool readFileToData(SInCatFile *c);
|
60 |
|
60 |
|
61 |
bool markRemoveFile(SInCatFile *f);
|
61 |
bool markRemoveFile(SInCatFile *f);
|
62 |
bool markRemoveFile(const Utils::String &filename);
|
62 |
bool markRemoveFile(const Utils::WString &filename);
|
63 |
|
63 |
|
64 |
int GetEndOffset();
|
64 |
int GetEndOffset();
|
65 |
size_t GetNumFiles() const;
|
65 |
size_t GetNumFiles() const;
|
66 |
SInCatFile *GetFile(unsigned int num) const;
|
66 |
SInCatFile *GetFile(unsigned int num) const;
|
67 |
|
67 |
|
68 |
unsigned char *UnpackFile ( SInCatFile *c, size_t *size);
|
68 |
unsigned char *UnpackFile ( SInCatFile *c, size_t *size);
|
69 |
|
69 |
|
70 |
static bool Opened(int error, bool allowCreate = true);
|
70 |
static bool Opened(int error, bool allowCreate = true);
|
71 |
bool removeFile(SInCatFile *f);
|
71 |
bool removeFile(SInCatFile *f);
|
72 |
bool removeFile(const Utils::String &filename);
|
72 |
bool removeFile(const Utils::WString &filename);
|
73 |
bool WriteCatFile ();
|
73 |
bool WriteCatFile ();
|
74 |
bool appendFile(const Utils::String &sFilename, const Utils::String &to, bool pck = true, bool bXor = true, Utils::String *sChangeTo = NULL);
|
74 |
bool appendFile(const Utils::WString &sFilename, const Utils::WString &to, bool pck = true, bool bXor = true, Utils::WString *sChangeTo = NULL);
|
75 |
bool appendData (unsigned char *data, size_t size, const Utils::String &to, bool pck = true, bool bXor = true );
|
75 |
bool appendData (unsigned char *data, size_t size, const Utils::WString &to, bool pck = true, bool bXor = true );
|
76 |
bool addData(const Utils::String &catfile, unsigned char *data, size_t size, const Utils::String &to, bool pck = true, bool create = true );
|
76 |
bool addData(const Utils::WString &catfile, unsigned char *data, size_t size, const Utils::WString &to, bool pck = true, bool create = true );
|
77 |
|
77 |
|
78 |
std::vector<SInCatFile *> *GetFiles() const;
|
78 |
std::vector<SInCatFile *> *GetFiles() const;
|
79 |
|
79 |
|
80 |
bool extractFile(const Utils::String &filename, const Utils::String &to = Utils::String::Null(), bool preserve = false);
|
80 |
bool extractFile(const Utils::WString &filename, const Utils::WString &to = Utils::WString::Null(), bool preserve = false);
|
81 |
bool extractFile(SInCatFile* f, const Utils::String &to = Utils::String::Null(), bool preserve = false);
|
81 |
bool extractFile(SInCatFile* f, const Utils::WString &to = Utils::WString::Null(), bool preserve = false);
|
82 |
bool extractAll(const Utils::String &dir);
|
82 |
bool extractAll(const Utils::WString &dir);
|
83 |
|
83 |
|
84 |
void clearError () { m_iError = CATERR_NONE; _sError.clear(); }
|
84 |
void clearError () { m_iError = CATERR_NONE; _sError.clear(); }
|
85 |
int error () const { return m_iError; }
|
85 |
int error () const { return m_iError; }
|
86 |
const Utils::String &errorString() const { return _sError; }
|
86 |
const Utils::WString &errorString() const { return _sError; }
|
87 |
Utils::String getErrorString () const;
|
87 |
Utils::WString getErrorString () const;
|
88 |
|
88 |
|
89 |
const Utils::String &internalDatFilename() const;
|
89 |
const Utils::WString &internalDatFilename() const;
|
90 |
const Utils::WString &catFilename() const { return m_fCatFile.fullFilename(); }
|
90 |
const Utils::WString &catFilename() const { return m_fCatFile.fullFilename(); }
|
91 |
const Utils::WString &datFilename() const { return m_fDatFile.fullFilename(); }
|
91 |
const Utils::WString &datFilename() const { return m_fDatFile.fullFilename(); }
|
92 |
|
92 |
|
93 |
bool writeFromCat(const Utils::String &catfile, const Utils::String &file);
|
93 |
bool writeFromCat(const Utils::WString &catfile, const Utils::WString &file);
|
94 |
bool writeFromCat(CCatFile* fcat, const Utils::String &file);
|
94 |
bool writeFromCat(CCatFile* fcat, const Utils::WString &file);
|
95 |
|
95 |
|
96 |
void findFiles(Utils::CStringList &list, const Utils::String &filemask) const;
|
96 |
void findFiles(Utils::WStringList &list, const Utils::WString &filemask) const;
|
97 |
|
97 |
|
98 |
private:
|
98 |
private:
|
99 |
void _clearFiles();
|
99 |
void _clearFiles();
|
100 |
int _checkFiletype(const unsigned char *pBuffer, int iSize);
|
100 |
int _checkFiletype(const unsigned char *pBuffer, int iSize);
|
101 |
void RemoveData ();
|
101 |
void RemoveData ();
|
Line 106... |
Line 106... |
106 |
unsigned char *m_sData;
|
106 |
unsigned char *m_sData;
|
107 |
size_t m_lSize;
|
107 |
size_t m_lSize;
|
108 |
char m_iDataType;
|
108 |
char m_iDataType;
|
109 |
|
109 |
|
110 |
std::vector<SInCatFile *> *_lFiles;
|
110 |
std::vector<SInCatFile *> *_lFiles;
|
111 |
Utils::String _sError;
|
111 |
Utils::WString _sError;
|
112 |
Utils::String _sAddonDir;
|
112 |
Utils::WString _sAddonDir;
|
113 |
|
113 |
|
114 |
Utils::String _sReadFilename;
|
114 |
Utils::WString _sReadFilename;
|
115 |
int m_iError;
|
115 |
int m_iError;
|
116 |
|
116 |
|
117 |
bool m_bCreate;
|
117 |
bool m_bCreate;
|
118 |
bool m_bCatChanged;
|
118 |
bool m_bCatChanged;
|
119 |
};
|
119 |
};
|