-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXPatcherFile.h
More file actions
78 lines (69 loc) · 1.98 KB
/
XPatcherFile.h
File metadata and controls
78 lines (69 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**************************************************************************
/* FileName: XPatcherFile.h
/* FileDesc: 补丁文件格式
/* FileAuthor: YangCao
/* CreateTime: 2014/11/30 23:42:30
/* CopyRight: yc
/*************************************************************************/
#ifndef __XPATCHERFILE__H
#define __XPATCHERFILE__H
#include "XFilePackage.h"
#include "XFilePackManager.h"
typedef void (*pfnApplyPatchCallBack)(int cur_apply, int total_apply);
class X_DLL XPathcherFile : public XFile
{
enum PatcherAction
{
PA_ADD_FILE,//添加文件
PA_REP_FILE,//更换文件
PA_DEL_FILE,//删除文件
PA_MOD_FILE,//更新文件
};
enum
{
PATCH_SAFE_SIZE = 1024,
};
struct DeleteItem
{
std::string path;//路径,如果不是包里那么统一放在更新目录下
std::string package;//仅当在某个包里是才填
DeleteItem()
{
path = "";
package = "";
}
};
struct AddItem
{
int compress_type;
std::string path;//路径,如果不是包里那么统一放在更新目录下
std::string package;//仅当在某个包里是才填
int buf_len;//压缩
int org_len;//原来压缩长度
AddItem()
{
compress_type = NONE_COMPRESS;
path = "";
package = "";
buf_len = 0;
org_len = 0;
}
};
public:
bool LoadPatch(const char* path);
bool ApplyPatch(XFilePackManage& pFilePackMan, const char* updatadir, pfnApplyPatchCallBack func = NULL);
bool AddFile(const char* src_file, const char* file, const char* package = NULL);
bool AddFile(const void* buf, int len, const char* file, const char* package = NULL);
bool DelFiles(std::vector<DeleteItem>& vecDelItems);
bool DelFile(const DeleteItem& delItem);
bool DelFile(const char* file, const char* package = NULL);
bool CreatePatch(const char* path);
bool FlushPath();
protected:
bool ReadFileContent(const AddItem& addItem, void** buff, int* len);
bool CompressFileData(const void** data, int len, int& outlen, int& compress_type, void** outBuffer);
protected:
std::vector<DeleteItem> patch_del_items;
//std::vector<AddItem> patch_add_items;
};
#endif // XPatcherFile