OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4Update.h
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
5  * Copyright (c) 2009-2016, The OpenClonk Team and contributors
6  *
7  * Distributed under the terms of the ISC license; see accompanying file
8  * "COPYING" for details.
9  *
10  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
11  * See accompanying file "TRADEMARK" for details.
12  *
13  * To redistribute this file separately, substitute the full license texts
14  * for the above references.
15  */
16 /* Update package support */
17 
18 #ifndef INC_C4GroupEx
19 
20 #define INC_C4GroupEx
21 
22 #include "lib/C4InputValidation.h"
23 
24 const int C4UP_MaxUpGrpCnt = 50;
25 
27 {
28 public:
29  int32_t RequireVersion[4] = { 0, 0, 0, 0 };
30  char Name[C4MaxName + 1] = { 0 };
31  char DestPath[_MAX_PATH + 1] = { 0 };
32  int32_t GrpUpdate = 0;
33  int32_t UpGrpCnt = 0; // number of file versions that can be updated by this package
34  uint32_t GrpChks1[C4UP_MaxUpGrpCnt] = { 0 }, GrpChks2 = 0;
35 public:
36  void CompileFunc(StdCompiler *pComp);
37  bool Load(C4Group &hGroup);
38  bool Save(C4Group &hGroup);
39 };
40 
41 #define C4UPD_CHK_OK 0
42 #define C4UPD_CHK_NO_SOURCE 1
43 #define C4UPD_CHK_BAD_SOURCE 2
44 #define C4UPD_CHK_ALREADY_UPDATED 3
45 #define C4UPD_CHK_BAD_VERSION 4
46 
48 {
49 
50 public:
51  bool Load(C4Group *pGroup);
52  bool Execute(C4Group *pGroup);
53  static bool Optimize(C4Group *pGrpFrom, const char *strTarget);
54  int Check(C4Group *pGroup);
55  bool MakeUpdate(const char *strFile1, const char *strFile2, const char *strUpdateFile, const char *strName = nullptr);
56 
57 protected:
58  bool DoUpdate(C4Group *pGrpFrom, class C4GroupEx *pGrpTo, const char *strFileName);
59  bool DoGrpUpdate(C4Group *pUpdateData, class C4GroupEx *pGrpTo);
60  static bool Optimize(C4Group *pGrpFrom, class C4GroupEx *pGrpTo, const char *strFileName);
61 
62  bool MkUp(C4Group *pGrp1, C4Group *pGrp2, C4GroupEx *pUpGr, bool *fModified);
63 
64  bool OpenUnpackParents(C4GroupEx &rGroup, const char *strGroup, const char *strEnsureMaker);
65 
67  void WriteLog(const char *strMsg, ...) GNUC_FORMAT_ATTRIBUTE_O;
68 };
69 
70 bool C4Group_ApplyUpdate(C4Group &hGroup, unsigned long ParentProcessID);
71 
72 #endif
const int C4UP_MaxUpGrpCnt
Definition: C4Update.h:24
bool MkUp(C4Group *pGrp1, C4Group *pGrp2, C4GroupEx *pUpGr, bool *fModified)
Definition: C4Update.cpp:694
void CompileFunc(StdCompiler *pComp)
Definition: C4Update.cpp:230
bool DoGrpUpdate(C4Group *pUpdateData, class C4GroupEx *pGrpTo)
Definition: C4Update.cpp:527
bool OpenUnpackParents(C4GroupEx &rGroup, const char *strGroup, const char *strEnsureMaker)
char DestPath[_MAX_PATH+1]
Definition: C4Update.h:31
int Check(C4Group *pGroup)
Definition: C4Update.cpp:431
#define _MAX_PATH
uint32_t GrpChks2
Definition: C4Update.h:34
#define GNUC_FORMAT_ATTRIBUTE_O
int32_t RequireVersion[4]
Definition: C4Update.h:29
uint32_t GrpChks1[C4UP_MaxUpGrpCnt]
Definition: C4Update.h:34
bool Execute(C4Group *pGroup)
Definition: C4Update.cpp:303
const unsigned int C4MaxName
int32_t GrpUpdate
Definition: C4Update.h:32
CStdFile Log
Definition: C4Update.h:66
bool Load(C4Group &hGroup)
Definition: C4Update.cpp:241
char Name[C4MaxName+1]
Definition: C4Update.h:30
bool DoUpdate(C4Group *pGrpFrom, class C4GroupEx *pGrpTo, const char *strFileName)
Definition: C4Update.cpp:472
void WriteLog(const char *strMsg,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: C4Update.cpp:825
static bool Optimize(C4Group *pGrpFrom, const char *strTarget)
Definition: C4Update.cpp:398
bool Load(C4Group *pGroup)
Definition: C4Update.cpp:280
bool Save(C4Group &hGroup)
Definition: C4Update.cpp:260
bool MakeUpdate(const char *strFile1, const char *strFile2, const char *strUpdateFile, const char *strName=nullptr)
Definition: C4Update.cpp:600
bool C4Group_ApplyUpdate(C4Group &hGroup, unsigned long ParentProcessID)
Definition: C4Update.cpp:42
int32_t UpGrpCnt
Definition: C4Update.h:33