Rev 1 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
#pragma once#include "CyString.h"#include "VirtualFileSystem.h"#include "lists.h"#include "StringList.h"using namespace SPK;enum {DIFFTYPE_ADDITION, DIFFTYPE_REMOVAL, DIFFTYPE_CHANGE};tstruct SDiffEntry {int iType;int iID;} SDiffEntry;tstruct SDiffEntryAddition : SDiffEntry {CyString sEntry;SDiffEntryAddition() { iType = DIFFTYPE_ADDITION; }} SDiffEntryAddition;tstruct SDiffEntryRemoval : SDiffEntry {SDiffEntryRemoval() { iType = DIFFTYPE_REMOVAL; }} SDiffEntryRemoval;tstruct SDiffEntryChange : SDiffEntry {SDiffEntryChange() { iType = DIFFTYPE_CHANGE; }int iPos;CyString sFrom;CyString sEntry;} SDiffEntryChange;tstruct SDiffFile {CyString sFile;CLinkList<SDiffEntry> m_lEntries;} SDiffFile;enum {MDERR_NONE, MDERR_FILENOTFOUND, MDERR_CANTOPEN, MDERR_CANTOPENMOD};tclass CModDiff{public:// staticstatic bool CanBeDiffed(const CyString &file);// constructorsCModDiff(CyString &dir, int maxPatch = 0);~CModDiff(void);// public functionsvoid SetTempDirectory(CyString &temp) { m_sTempDir = temp; }bool LoadDirectory(CyString &dir);bool IsLoaded() { return m_bLoaded; }const CyString &GetDirectory() { return m_sCurrentDir; }bool CreateDiff(CyString &mod);bool DiffFile(CyString &baseFile, CyString &modFile, CyString &fileType);void Clean();bool WriteDiff(CyString &file);bool ReadDiff(CyString &file);bool ApplyDiff(CyString &mod);bool ApplyMod(CyString &mod);void SetMaxPatch(int patch) { m_iMaxPatch = patch; }CLinkList<SDiffFile> &GetDiffFiles() { return m_lFiles; }void ClearError() { m_iError = MDERR_NONE; }int Error() { return m_iError; }private:// private functionsint GetAmountPosition(const CyString &fileType);bool IsLineComplete(CyString &line, CyString &fileType, bool first);bool ReadGameFile(CyString &file, CyStringList *lines, int *id);void CompareLine(CyString &line1, CyString &line2, int type, int id, SDiffFile *diffFile);bool ValidFile(CyString &file);// VariablesCyString m_sCurrentDir; // the current game directory (that the VFS is opened too)CyString m_sTempDir; // temporary dir (used to write temporary files to)CVirtualFileSystem m_fileSystem; // the VFS of the game directory (for finding the files to use)CLinkList<SDiffFile> m_lFiles; // list of files that have changedbool m_bLoaded; // if the directory is loaded and ready to be diffedint m_iError; // error id of processint m_iMaxPatch; // The max fake patch to check to};