| 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 |
CyString sFile;
|
16 |
Utils::String 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 CyString PckChangeExtension ( CyString f );
|
36 |
static Utils::String PckChangeExtension(const Utils::String &f);
|
| 37 |
static CyString RenameFileExtension(SInCatFile *f);
|
37 |
static Utils::String RenameFileExtension(SInCatFile *f);
|
| 38 |
static bool IsAddonDir(CyString dir);
|
38 |
static bool IsAddonDir(CyString dir);
|
| 39 |
static bool CheckPackedExtension(const Utils::String &sFilename);
|
39 |
static bool CheckPackedExtension(const Utils::String &sFilename);
|
| 40 |
|
40 |
|
| 41 |
public:
|
41 |
public:
|
| 42 |
CCatFile ();
|
42 |
CCatFile ();
|
| Line 48... |
Line 48... |
| 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 ( CyString filename );
|
53 |
bool checkExtensionPck(const Utils::String &filename) const;
|
| 54 |
|
54 |
|
| 55 |
unsigned char *readData ( CyString filename, size_t *size );
|
55 |
unsigned char *readData ( CyString 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 ( CyString filename );
|
57 |
SInCatFile *FindData(CyString filename);
|
| - |
|
58 |
SInCatFile *findData(const Utils::String &filename) const;
|
| 58 |
bool ReadFileToData ( CyString filename );
|
59 |
bool ReadFileToData ( CyString filename );
|
| 59 |
bool ReadFileToData ( SInCatFile *c );
|
60 |
bool ReadFileToData ( SInCatFile *c );
|
| 60 |
|
61 |
|
| 61 |
bool MarkRemoveFile ( SInCatFile *f );
|
62 |
bool MarkRemoveFile ( SInCatFile *f );
|
| 62 |
bool MarkRemoveFile ( CyString filename );
|
63 |
bool MarkRemoveFile ( CyString filename );
|
| 63 |
|
64 |
|
| 64 |
int GetEndOffset();
|
65 |
int GetEndOffset();
|
| 65 |
int GetNumFiles () { return m_lFiles.size(); }
|
66 |
size_t GetNumFiles() const;
|
| 66 |
SInCatFile *GetFile ( int num ) { return m_lFiles.Get(num); }
|
67 |
SInCatFile *GetFile(unsigned int num) const;
|
| 67 |
|
68 |
|
| 68 |
unsigned char *UnpackFile ( SInCatFile *c, size_t *size);
|
69 |
unsigned char *UnpackFile ( SInCatFile *c, size_t *size);
|
| 69 |
|
70 |
|
| 70 |
static bool Opened(int error, bool allowCreate = true);
|
71 |
static bool Opened(int error, bool allowCreate = true);
|
| 71 |
bool RemoveFile ( SInCatFile *f );
|
72 |
bool removeFile(SInCatFile *f);
|
| 72 |
bool RemoveFile ( CyString filename );
|
73 |
bool removeFile(const Utils::String &filename);
|
| 73 |
bool WriteCatFile ();
|
74 |
bool WriteCatFile ();
|
| 74 |
bool AppendFile(const Utils::String &sFilename, const Utils::String &to, bool pck = true, bool bXor = true, Utils::String *sChangeTo = NULL);
|
75 |
bool AppendFile(const Utils::String &sFilename, const Utils::String &to, bool pck = true, bool bXor = true, Utils::String *sChangeTo = NULL);
|
| 75 |
bool AppendData ( unsigned char *data, size_t size, CyString to, bool pck = true, bool bXor = true );
|
76 |
bool AppendData ( unsigned char *data, size_t size, CyString to, bool pck = true, bool bXor = true );
|
| 76 |
bool AddData ( CyString catfile, unsigned char *data, size_t size, CyString to, bool pck = true, bool create = true );
|
77 |
bool AddData ( CyString catfile, unsigned char *data, size_t size, CyString to, bool pck = true, bool create = true );
|
| 77 |
|
78 |
|
| 78 |
CyString ChangeExtension ( CyString f );
|
79 |
CyString ChangeExtension ( CyString f );
|
| 79 |
CLinkList<SInCatFile> *GetFiles() { return &m_lFiles; }
|
80 |
std::vector<SInCatFile *> *GetFiles() const;
|
| 80 |
|
81 |
|
| 81 |
bool ExtractFile ( CyString filename, CyString to = NullString, bool preserve = false );
|
82 |
bool ExtractFile ( CyString filename, CyString to = NullString, bool preserve = false );
|
| 82 |
bool ExtractFile ( SInCatFile *f, CyString to = NullString, bool preserve = false );
|
83 |
bool ExtractFile ( SInCatFile *f, CyString to = NullString, bool preserve = false );
|
| 83 |
bool ExtractAll (CyString dir);
|
84 |
bool ExtractAll (CyString dir);
|
| 84 |
|
85 |
|
| 85 |
void ClearError () { m_iError = CATERR_NONE; m_sError = ""; }
|
86 |
void clearError () { m_iError = CATERR_NONE; _sError.clear(); }
|
| 86 |
int Error () { return m_iError; }
|
87 |
int error () const { return m_iError; }
|
| 87 |
CyString ErrorString() { return m_sError; }
|
88 |
const Utils::String &errorString() const { return _sError; }
|
| 88 |
CyString GetErrorString ();
|
89 |
Utils::String getErrorString () const;
|
| 89 |
|
90 |
|
| 90 |
const Utils::String &internalDatFilename() const;
|
91 |
const Utils::String &internalDatFilename() const;
|
| 91 |
const Utils::String &catFilename() { return m_fCatFile.fullFilename(); }
|
92 |
const Utils::String &catFilename() const { return m_fCatFile.fullFilename(); }
|
| 92 |
const Utils::String &datFilename() { return m_fDatFile.fullFilename(); }
|
93 |
const Utils::String &datFilename() const { return m_fDatFile.fullFilename(); }
|
| 93 |
|
94 |
|
| 94 |
bool WriteFromCat ( CyString catfile, CyString file );
|
95 |
bool WriteFromCat ( CyString catfile, CyString file );
|
| 95 |
bool WriteFromCat ( CCatFile *fcat, CyString file );
|
96 |
bool WriteFromCat ( CCatFile *fcat, CyString file );
|
| 96 |
|
97 |
|
| 97 |
void FindFiles(CyStringList *list, CyString filemask);
|
98 |
void FindFiles(CyStringList *list, CyString filemask);
|
| Line 107... |
Line 108... |
| 107 |
|
108 |
|
| 108 |
unsigned char *m_sData;
|
109 |
unsigned char *m_sData;
|
| 109 |
size_t m_lSize;
|
110 |
size_t m_lSize;
|
| 110 |
char m_iDataType;
|
111 |
char m_iDataType;
|
| 111 |
|
112 |
|
| 112 |
CLinkList<SInCatFile> m_lFiles;
|
113 |
std::vector<SInCatFile *> *_lFiles;
|
| 113 |
CyString m_sError;
|
114 |
Utils::String _sError;
|
| 114 |
CyString m_sAddonDir;
|
115 |
Utils::String _sAddonDir;
|
| 115 |
|
116 |
|
| 116 |
Utils::String _sReadFilename;
|
117 |
Utils::String _sReadFilename;
|
| 117 |
int m_iError;
|
118 |
int m_iError;
|
| 118 |
|
119 |
|
| 119 |
bool m_bCreate;
|
120 |
bool m_bCreate;
|