Line 78... |
Line 78... |
78 |
|
78 |
|
79 |
class SPKEXPORT CBaseFile : public SPK::Package::CCorePackage
|
79 |
class SPKEXPORT CBaseFile : public SPK::Package::CCorePackage
|
80 |
{
|
80 |
{
|
81 |
public:
|
81 |
public:
|
82 |
// static functions
|
82 |
// static functions
|
83 |
static Utils::String ConvertGameToString(int game);
|
83 |
static Utils::WString ConvertGameToString(int game);
|
84 |
static int GetGameFromString(const Utils::String &game);
|
84 |
static int GetGameFromString(const Utils::String &game);
|
85 |
static Utils::String ErrorString(int error, const Utils::String &errorStr = Utils::String::Null());
|
85 |
static Utils::WString ErrorString(int error, const Utils::WString &errorStr = Utils::WString::Null());
|
86 |
static Utils::String GetEndOfLine(FILE* id, int* line = NULL, bool upper = true);
|
86 |
static Utils::String GetEndOfLine(FILE* id, int* line = NULL, bool upper = true);
|
87 |
static int CheckFile(const Utils::String &filename, float* version = NULL);
|
87 |
static int CheckFile(const Utils::WString &filename, float* version = NULL);
|
88 |
|
88 |
|
89 |
|
89 |
|
90 |
CBaseFile();
|
90 |
CBaseFile();
|
91 |
virtual ~CBaseFile();
|
91 |
virtual ~CBaseFile();
|
92 |
|
92 |
|
Line 95... |
Line 95... |
95 |
virtual Utils::String getFullPackageName(int language, bool includeVersion = true, const Utils::String &byString = "by") const;
|
95 |
virtual Utils::String getFullPackageName(int language, bool includeVersion = true, const Utils::String &byString = "by") const;
|
96 |
virtual Utils::String getFullPackageName(const Utils::String &format, int lang) const;
|
96 |
virtual Utils::String getFullPackageName(const Utils::String &format, int lang) const;
|
97 |
|
97 |
|
98 |
virtual Utils::String createValuesLine() const;
|
98 |
virtual Utils::String createValuesLine() const;
|
99 |
|
99 |
|
100 |
virtual bool LoadPackageData(const Utils::String& sFirst, const Utils::String& sRest, const Utils::String& sMainGame, Utils::CStringList& otherGames, Utils::CStringList& gameAddons, CProgressInfo* progress);
|
100 |
virtual bool loadPackageData(const Utils::WString& sFirst, const Utils::WString& sRest, const Utils::WString& sMainGame, Utils::WStringList& otherGames, Utils::WStringList& gameAddons, CProgressInfo* progress);
|
101 |
virtual bool GeneratePackagerScript(bool wildcard, Utils::CStringList* list, int game, const Utils::CStringList& gameAddons, bool datafile = false);
|
101 |
virtual bool GeneratePackagerScript(bool wildcard, Utils::CStringList* list, int game, const Utils::CStringList& gameAddons, bool datafile = false);
|
102 |
virtual bool GeneratePackagerScriptFile(bool wildcard, Utils::CStringList* list, int game, const Utils::CStringList& gameAddons);
|
102 |
virtual bool GeneratePackagerScriptFile(bool wildcard, Utils::CStringList* list, int game, const Utils::CStringList& gameAddons);
|
103 |
|
103 |
|
104 |
// Getters
|
104 |
// Getters
|
105 |
Utils::String getNameValidFile() const;
|
105 |
Utils::WString getNameValidFile() const;
|
106 |
const CLinkList<C_File> &fileList() const;
|
106 |
const CLinkList<C_File> &fileList() const;
|
107 |
CLinkList<C_File>& fileList(FileType type, CLinkList<C_File> &list) const;
|
107 |
CLinkList<C_File>& fileList(FileType type, CLinkList<C_File> &list) const;
|
108 |
CLinkList<C_File>& fileList(FileType type);
|
108 |
CLinkList<C_File>& fileList(FileType type);
|
109 |
CLinkList<C_File> *GetFileList() { return &m_lFiles; }
|
109 |
CLinkList<C_File> *GetFileList() { return &m_lFiles; }
|
110 |
C_File *icon() const { return m_pIconFile; }
|
110 |
C_File *icon() const { return m_pIconFile; }
|
111 |
const Utils::String &iconExt() const { return _sIconExt; }
|
111 |
const Utils::WString &iconExt() const { return _sIconExt; }
|
112 |
int dataCompression () const { return m_SHeader2.iDataCompression; }
|
112 |
int dataCompression () const { return m_SHeader2.iDataCompression; }
|
113 |
float fileVersion () const { return m_SHeader.fVersion; }
|
113 |
float fileVersion () const { return m_SHeader.fVersion; }
|
114 |
size_t fileSize() const;
|
114 |
size_t fileSize() const;
|
115 |
//const Utils::String& getLanguageName(int lang) const { return name(lang); }
|
115 |
//const Utils::String& getLanguageName(int lang) const { return name(lang); }
|
116 |
Utils::String getAutosaveName() const;
|
116 |
Utils::String getAutosaveName() const;
|
Line 130... |
Line 130... |
130 |
// Game Compatability
|
130 |
// Game Compatability
|
131 |
SGameCompat* GetGameCompatability(int game);
|
131 |
SGameCompat* GetGameCompatability(int game);
|
132 |
bool RemoveGameCompatability(int game);
|
132 |
bool RemoveGameCompatability(int game);
|
133 |
void AddGameCompatability(int game, const Utils::String &version);
|
133 |
void AddGameCompatability(int game, const Utils::String &version);
|
134 |
bool CheckGameCompatability(int game);
|
134 |
bool CheckGameCompatability(int game);
|
135 |
bool checkGameVersionCompatability(int game, const Utils::String &sVersion, int iVersion) const;
|
135 |
bool checkGameVersionCompatability(int game, const Utils::WString &sVersion, int iVersion) const;
|
136 |
bool AnyGameCompatability() { return !m_lGames.empty(); }
|
136 |
bool AnyGameCompatability() { return !m_lGames.empty(); }
|
137 |
|
137 |
|
138 |
// Web Mirrors
|
138 |
// Web Mirrors
|
139 |
bool anyWebMirrors() { return !_lMirrors.empty(); }
|
139 |
bool anyWebMirrors() { return !_lMirrors.empty(); }
|
140 |
const Utils::CStringList &webMirrors() const { return _lMirrors; }
|
140 |
const Utils::CStringList &webMirrors() const { return _lMirrors; }
|
Line 153... |
Line 153... |
153 |
void convertAutoText(C_File *f) const;
|
153 |
void convertAutoText(C_File *f) const;
|
154 |
void renameFile(C_File *f, const Utils::String &baseName) const;
|
154 |
void renameFile(C_File *f, const Utils::String &baseName) const;
|
155 |
|
155 |
|
156 |
size_t countFiles(FileType filetype) const;
|
156 |
size_t countFiles(FileType filetype) const;
|
157 |
C_File* findFileAt(FileType filetype, size_t pos) const;
|
157 |
C_File* findFileAt(FileType filetype, size_t pos) const;
|
158 |
C_File* findFile(const Utils::String& file, FileType type, const Utils::String& dir = Utils::String::Null(), int game = 0) const;
|
158 |
C_File* findFile(const Utils::WString& file, FileType type, const Utils::WString& dir = Utils::WString::Null(), int game = 0) const;
|
159 |
|
159 |
|
160 |
void AddFileScript(FileType filetype, bool shared, bool packed, const Utils::String &rest, const Utils::String &sMainGame, Utils::CStringList &otherGames, Utils::CStringList &gameAddons, CProgressInfo *progress = NULL);
|
160 |
void addFileScript(FileType filetype, bool shared, bool packed, const Utils::WString &rest, const Utils::WString &sMainGame, Utils::WStringList &otherGames, Utils::WStringList &gameAddons, CProgressInfo *progress = NULL);
|
161 |
void AddFile(C_File* file);
|
161 |
void AddFile(C_File* file);
|
162 |
C_File* addFile(const Utils::String& file, const Utils::String& dir, FileType type, int game = 0, bool packed = false);
|
162 |
C_File* addFile(const Utils::WString& file, const Utils::WString& dir, FileType type, int game = 0, bool packed = false);
|
163 |
C_File* appendFile(const Utils::String& file, int type, int game, bool packed, const Utils::String& dir = Utils::String::Null(), CProgressInfo* progress = NULL);
|
163 |
C_File* appendFile(const Utils::WString& file, int type, int game, bool packed, const Utils::WString& dir = Utils::WString::Null(), CProgressInfo* progress = NULL);
|
164 |
bool addFileNow(const Utils::String&, const Utils::String&, FileType type, CProgressInfo* progress = NULL);
|
164 |
bool addFileNow(const Utils::String&, const Utils::String&, FileType type, CProgressInfo* progress = NULL);
|
165 |
bool removeFile(size_t pos);
|
165 |
bool removeFile(size_t pos);
|
166 |
bool removeFile(C_File* files);
|
166 |
bool removeFile(C_File* files);
|
167 |
bool removeFile(const Utils::String &file, FileType type, const Utils::String &dir = Utils::String::Null(), int game = 0);
|
167 |
bool removeFile(const Utils::String &file, FileType type, const Utils::String &dir = Utils::String::Null(), int game = 0);
|
168 |
void removeAllFiles(FileType type, int game);
|
168 |
void removeAllFiles(FileType type, int game);
|
Line 170... |
Line 170... |
170 |
Utils::String createFilesLine(SSPKHeader2 *header, CProgressInfo* = NULL) const;
|
170 |
Utils::String createFilesLine(SSPKHeader2 *header, CProgressInfo* = NULL) const;
|
171 |
|
171 |
|
172 |
// error handling
|
172 |
// error handling
|
173 |
void ClearError () { _sLastError = ""; _iLastError = SPKERR_NONE; }
|
173 |
void ClearError () { _sLastError = ""; _iLastError = SPKERR_NONE; }
|
174 |
int lastError() const { return _iLastError; }
|
174 |
int lastError() const { return _iLastError; }
|
175 |
const Utils::String lastErrorString() const { return _sLastError; }
|
175 |
const Utils::WString lastErrorString() const { return _sLastError; }
|
176 |
|
176 |
|
177 |
virtual bool writeHeader(CFileIO &file, int iHeader, int iLength) const;
|
177 |
virtual bool writeHeader(CFileIO &file, int iHeader, int iLength) const;
|
178 |
virtual bool writeData(CFileIO &file, CProgressInfo * = NULL) const;
|
178 |
virtual bool writeData(CFileIO &file, CProgressInfo * = NULL) const;
|
179 |
virtual bool writeFile(const Utils::String &filename, CProgressInfo* = NULL) const;
|
179 |
virtual bool writeFile(const Utils::String &filename, CProgressInfo* = NULL) const;
|
180 |
virtual bool readFile(const Utils::String &filename, int readType = SPKREAD_ALL, CProgressInfo *progress = NULL);
|
180 |
virtual bool readFile(const Utils::String &filename, int readType = SPKREAD_ALL, CProgressInfo *progress = NULL);
|
181 |
bool readFile(CFileIO &File, int readtype, CProgressInfo *progress);
|
181 |
bool readFile(CFileIO &File, int readtype, CProgressInfo *progress);
|
182 |
|
182 |
|
183 |
virtual bool extractFile(int file, const Utils::String &dir, bool includedir = true, CProgressInfo *progress = NULL);
|
183 |
virtual bool extractFile(int file, const Utils::String &dir, bool includedir = true, CProgressInfo *progress = NULL);
|
184 |
virtual bool extractFile(C_File *file, const Utils::String &dir, bool includedir = true, CProgressInfo *progress = NULL);
|
184 |
virtual bool extractFile(C_File *file, const Utils::String &dir, bool includedir = true, CProgressInfo *progress = NULL);
|
185 |
virtual bool extractFile(int filenum, const Utils::String &dir, unsigned int game, const Utils::CStringList &gameAddons, bool includedir = true, CProgressInfo *progress = NULL);
|
185 |
virtual bool extractFile(int filenum, const Utils::String &dir, unsigned int game, const Utils::WStringList &gameAddons, bool includedir = true, CProgressInfo *progress = NULL);
|
186 |
virtual bool extractFile(C_File *file, const Utils::String &dir, unsigned int game, const Utils::CStringList &gameAddons, bool includedir = true, CProgressInfo *progress = NULL);
|
186 |
virtual bool extractFile(C_File *file, const Utils::String &dir, unsigned int game, const Utils::WStringList &gameAddons, bool includedir = true, CProgressInfo *progress = NULL);
|
187 |
virtual bool extractAll(const Utils::String &dir, int game, const Utils::CStringList &gameAddons, bool includedir = true, CProgressInfo *progress = NULL);
|
187 |
virtual bool extractAll(const Utils::String &dir, int game, const Utils::CStringList &gameAddons, bool includedir = true, CProgressInfo *progress = NULL);
|
188 |
|
188 |
|
189 |
virtual bool saveToArchive(const Utils::String &filename, int game, const CGameExe *exes, CProgressInfo *progress = NULL);
|
189 |
virtual bool saveToArchive(const Utils::String &filename, int game, const CGameExe *exes, CProgressInfo *progress = NULL);
|
190 |
virtual void addGeneratedFiles(HZIP &hz) {};
|
190 |
virtual void addGeneratedFiles(HZIP &hz) {};
|
191 |
|
191 |
|
Line 203... |
Line 203... |
203 |
|
203 |
|
204 |
bool IsFileAdded(C_File *f) { return m_lFiles.FindData(f); }
|
204 |
bool IsFileAdded(C_File *f) { return m_lFiles.FindData(f); }
|
205 |
|
205 |
|
206 |
// installing
|
206 |
// installing
|
207 |
void SwitchFilePointer(C_File *oldFile, C_File *newFile);
|
207 |
void SwitchFilePointer(C_File *oldFile, C_File *newFile);
|
208 |
bool installFiles(const Utils::String &destdir, CProgressInfo *progress, CLinkList<C_File> *spklist, Utils::CStringList *errorStr, bool enabled = true, CPackages *packages = NULL );
|
208 |
bool installFiles(const Utils::WString &destdir, CProgressInfo *progress, CLinkList<C_File> *spklist, Utils::WStringList *errorStr, bool enabled = true, CPackages *packages = NULL );
|
209 |
virtual bool IsPatch () { return false; }
|
209 |
virtual bool IsPatch () { return false; }
|
210 |
|
210 |
|
211 |
// installer functions
|
211 |
// installer functions
|
212 |
bool IsProfileEnabled () { return m_bProfile; }
|
212 |
bool IsProfileEnabled () { return m_bProfile; }
|
213 |
bool IsEnabled () { return m_bEnable; }
|
213 |
bool IsEnabled () { return m_bEnable; }
|
Line 225... |
Line 225... |
225 |
|
225 |
|
226 |
virtual bool ParseValueLine(const Utils::String &line);
|
226 |
virtual bool ParseValueLine(const Utils::String &line);
|
227 |
|
227 |
|
228 |
CLinkList<SGameCompat> *GetGameCompatabilityList() { return &m_lGames; }
|
228 |
CLinkList<SGameCompat> *GetGameCompatabilityList() { return &m_lGames; }
|
229 |
|
229 |
|
230 |
Utils::String fileSizeString() const;
|
230 |
Utils::WString fileSizeString() const;
|
231 |
|
231 |
|
232 |
CLinkList<SNeededLibrary> *GetNeededLibraries() { return &m_lNeededLibrarys; }
|
232 |
CLinkList<SNeededLibrary> *GetNeededLibraries() { return &m_lNeededLibrarys; }
|
233 |
void AddNeededLibrary(const Utils::String &scriptName, const Utils::String &author, const Utils::String &minVersion);
|
233 |
void AddNeededLibrary(const Utils::String &scriptName, const Utils::String &author, const Utils::String &minVersion);
|
234 |
bool IsPackageNeeded(const Utils::String &scriptName, const Utils::String &author);
|
234 |
bool IsPackageNeeded(const Utils::String &scriptName, const Utils::String &author);
|
235 |
SNeededLibrary *FindPackageNeeded(const Utils::String &scriptName, const Utils::String &author);
|
235 |
SNeededLibrary *FindPackageNeeded(const Utils::String &scriptName, const Utils::String &author);
|
Line 243... |
Line 243... |
243 |
bool anyFakePatchOrder() const { if ( !_lFakePatchBefore.empty() || !_lFakePatchAfter.empty() ) return true; return false; }
|
243 |
bool anyFakePatchOrder() const { if ( !_lFakePatchBefore.empty() || !_lFakePatchAfter.empty() ) return true; return false; }
|
244 |
const Utils::CStringList &getFakePatchBeforeOrder() const { return _lFakePatchBefore; }
|
244 |
const Utils::CStringList &getFakePatchBeforeOrder() const { return _lFakePatchBefore; }
|
245 |
const Utils::CStringList &getFakePatchAfterOrder() const { return _lFakePatchAfter; }
|
245 |
const Utils::CStringList &getFakePatchAfterOrder() const { return _lFakePatchAfter; }
|
246 |
void updateTextDB() { this->_resetTextDB(); }
|
246 |
void updateTextDB() { this->_resetTextDB(); }
|
247 |
|
247 |
|
248 |
virtual bool readWares(int iLang, CLinkList<SWareEntry> &list, const Utils::String &empWares);
|
248 |
virtual bool readWares(int iLang, CLinkList<SWareEntry> &list, const Utils::WString &empWares);
|
249 |
virtual bool readCommands(int iLang, CLinkList<SCommandSlot> &list);
|
249 |
virtual bool readCommands(int iLang, CLinkList<SCommandSlot> &list);
|
250 |
virtual bool readWingCommands(int iLang, CLinkList<SCommandSlot> &list);
|
250 |
virtual bool readWingCommands(int iLang, CLinkList<SCommandSlot> &list);
|
251 |
|
251 |
|
252 |
int FindFirstGameInPackage();
|
252 |
int FindFirstGameInPackage();
|
253 |
bool IsAnyGameInPackage();
|
253 |
bool IsAnyGameInPackage();
|
Line 270... |
Line 270... |
270 |
virtual bool IsSigned () { return m_bSigned;}
|
270 |
virtual bool IsSigned () { return m_bSigned;}
|
271 |
void SetOverrideFiles(bool b) { m_bOverrideFiles = b; }
|
271 |
void SetOverrideFiles(bool b) { m_bOverrideFiles = b; }
|
272 |
bool IsUpdateChecked () { return m_bUpdate; }
|
272 |
bool IsUpdateChecked () { return m_bUpdate; }
|
273 |
void SetUpdateChecked ( bool en ) { m_bUpdate = en; }
|
273 |
void SetUpdateChecked ( bool en ) { m_bUpdate = en; }
|
274 |
|
274 |
|
275 |
unsigned char *CreateData(size_t *size, CProgressInfo *progress = NULL);
|
275 |
unsigned char *createData(size_t *size, CProgressInfo *progress = NULL);
|
276 |
|
276 |
|
277 |
protected:
|
277 |
protected:
|
278 |
virtual void Delete ();
|
278 |
virtual void Delete ();
|
279 |
virtual void SetDefaults ();
|
279 |
virtual void SetDefaults ();
|
280 |
|
280 |
|
Line 286... |
Line 286... |
286 |
void _readValues(const Utils::String& values);
|
286 |
void _readValues(const Utils::String& values);
|
287 |
void _readFiles(const Utils::String& values);
|
287 |
void _readFiles(const Utils::String& values);
|
288 |
|
288 |
|
289 |
void _install_adjustFakePatches(CPackages *pPackages);
|
289 |
void _install_adjustFakePatches(CPackages *pPackages);
|
290 |
void _install_renameText(CPackages *pPackages);
|
290 |
void _install_renameText(CPackages *pPackages);
|
291 |
bool _install_uncompress(C_File *fit, CProgressInfo *progress, Utils::CStringList *errorStr, bool *uncomprToFile);
|
291 |
bool _install_uncompress(C_File *fit, CProgressInfo *progress, Utils::WStringList *errorStr, bool *uncomprToFile);
|
292 |
bool _install_setEnabled(bool bEnable, C_File *fit);
|
292 |
bool _install_setEnabled(bool bEnable, C_File *fit);
|
293 |
bool _install_checkVersion(C_File *pFile, const Utils::String &sDestination);
|
293 |
bool _install_checkVersion(C_File *pFile, const Utils::WString &sDestination);
|
294 |
Utils::String _install_adjustFilepointer(C_File *pFile, bool bEnabled, const Utils::String &sDestination);
|
294 |
Utils::String _install_adjustFilepointer(C_File *pFile, bool bEnabled, const Utils::WString &sDestination);
|
295 |
C_File *_install_checkFile(C_File *pFile, Utils::CStringList *errorStr, bool *bDoFile, CLinkList<C_File> *pFileList);
|
295 |
C_File *_install_checkFile(C_File *pFile, Utils::WStringList *errorStr, bool *bDoFile, CLinkList<C_File> *pFileList);
|
296 |
bool _install_checkFileEnable(C_File *pCheckFile, C_File *fit, const Utils::String &sDestination, bool bEnabled, Utils::CStringList *errorStr);
|
296 |
bool _install_checkFileEnable(C_File *pCheckFile, C_File *fit, const Utils::WString &sDestination, bool bEnabled, Utils::WStringList *errorStr);
|
297 |
bool _install_createDirectory(CDirIO &Dir, const Utils::String &sTo, C_File *pFile, Utils::CStringList *errorStr);
|
297 |
bool _install_createDirectory(CDirIO &Dir, const Utils::WString &sTo, C_File *pFile, Utils::WStringList *errorStr);
|
298 |
void _install_writeFile(C_File *pFile, const Utils::String &sDestination, Utils::CStringList *errorStr);
|
298 |
void _install_writeFile(C_File *pFile, const Utils::WString &sDestination, Utils::WStringList *errorStr);
|
299 |
|
299 |
|
300 |
int _read_FileHeader(CFileIO &File, int iReadType, int iMaxProgress, int iDoneLen, CProgressInfo *pProgress);
|
300 |
int _read_FileHeader(CFileIO &File, int iReadType, int iMaxProgress, int iDoneLen, CProgressInfo *pProgress);
|
301 |
int _read_Header(CFileIO &File, int iReadType, int iMaxProgress, CProgressInfo *pProgress);
|
301 |
int _read_Header(CFileIO &File, int iReadType, int iMaxProgress, CProgressInfo *pProgress);
|
302 |
CFileIO *_startRead();
|
302 |
CFileIO *_startRead();
|
303 |
|
303 |
|
304 |
void _addFile(C_File *file, bool dontChange = false);
|
304 |
void _addFile(C_File *file, bool dontChange = false);
|
305 |
void _updateTextDB(C_File *file);
|
305 |
void _updateTextDB(C_File *file);
|
306 |
void _resetTextDB();
|
306 |
void _resetTextDB();
|
307 |
void _addWaresToList(int iLang, CLinkList<SWareEntry> &list, const Utils::String &wares, enum WareTypes eType);
|
307 |
void _addWaresToList(int iLang, CLinkList<SWareEntry> &list, const Utils::WString &wares, enum WareTypes eType);
|
308 |
bool _readCommands(int iLang, int iStartID, CLinkList<SCommandSlot> &list);
|
308 |
bool _readCommands(int iLang, int iStartID, CLinkList<SCommandSlot> &list);
|
309 |
Utils::WString _replaceFilename(const Utils::WString &fname);
|
309 |
Utils::WString _replaceFilename(const Utils::WString &fname);
|
310 |
|
310 |
|
311 |
protected:
|
311 |
protected:
|
312 |
SSPKHeader m_SHeader;
|
312 |
SSPKHeader m_SHeader;
|
313 |
SSPKHeader2 m_SHeader2;
|
313 |
SSPKHeader2 m_SHeader2;
|
314 |
|
314 |
|
315 |
C_File *m_pIconFile;
|
315 |
C_File *m_pIconFile;
|
316 |
Utils::String _sIconExt;
|
316 |
Utils::WString _sIconExt;
|
317 |
Utils::String _sLastError;
|
317 |
Utils::WString _sLastError;
|
318 |
int _iLastError;
|
318 |
int _iLastError;
|
319 |
|
319 |
|
320 |
CLinkList<C_File> m_lFiles;
|
320 |
CLinkList<C_File> m_lFiles;
|
321 |
CLinkList<C_File> m_lTempFiles;
|
321 |
CLinkList<C_File> m_lTempFiles;
|
322 |
Utils::CStringList _lMirrors; //TODO: move to CorePackage
|
322 |
Utils::CStringList _lMirrors; //TODO: move to CorePackage
|