-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPatchedInfo.cpp
More file actions
135 lines (110 loc) · 2.83 KB
/
PatchedInfo.cpp
File metadata and controls
135 lines (110 loc) · 2.83 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#include "stdafx.h"
#include "PatchedInfo.h"
PatchedInfo::PatchedInfo()
{
}
PatchedInfo::~PatchedInfo()
{
Clear();
}
bool PatchedInfo::LoadTPFFile( const char* szFileName )
{
FILE *fp = NULL;
if( fopen_s( &fp, szFileName, "r" ) != 0 )
{
return false;
}
if( !fp )
{
return false;
}
char buf[2048];
while( !feof( fp ) )
{
memset( buf, 0, sizeof(buf) );
fgets( buf, sizeof(buf), fp );
if( buf[0] == '\r' )
continue;
if( buf[0] == '\n' )
continue;
if( buf[0] == '#' )
continue;
XStringUtil::TrimRight( buf );
std::vector< std::string > vList;
XStringUtil::Split( buf, vList, ":", false );
// ÆÄÀÏ Á¤º¸¶ó¸é
if( vList.size() >= 8 )
{
std::string & strApplicationName = vList[0];
std::string & strVersion = vList[1];
std::string & strFileName = vList[2];
std::string & strSizeBefore = vList[3];
std::string & strChecksumBefore = vList[4];
std::string & strSizeAfter = vList[5];
std::string & strChecksumAfter = vList[6];
std::string strDirectory = vList.size() > 7 ? vList[7] : "";
std::string strDescription = vList.size() > 8 ? vList[8] : "";
if( strFileName.empty() || strVersion.empty() || strSizeBefore.empty() || strChecksumBefore.empty() || strSizeAfter.empty() || strChecksumAfter.empty() || strApplicationName.empty() )
{
break;
}
if( strDirectory.empty() ) strDirectory = "/";
AddPatchFileInfo( strFileName, strVersion, strSizeBefore, strChecksumBefore, strSizeAfter, strChecksumAfter, strApplicationName, strDirectory, strDescription );
}
}
fclose( fp );
return true;
}
void PatchedInfo::Clear()
{
if( m_file_hash.size() > 0 )
{
PatchFileInfo* pInfo = NULL;
m_file_hash.get_first_value( pInfo );
do
{
if( pInfo != NULL )
{
delete pInfo;
pInfo = NULL;
}
} while( m_file_hash.get_next_value( pInfo ) );
}
m_file_hash.clear();
}
bool PatchedInfo::IsPatchedFile( const std::string & _strFileName,
size_t _nSizeBefore,
int _nChecksumBefore,
size_t _nSizeAfter,
int _nChecksumAfter ) const
{
PatchFileInfo* file = NULL;
m_file_hash.lookup( _strFileName.c_str(), file );
if( file != NULL )
{
return file->IsEqual( _nSizeBefore, _nChecksumBefore, _nSizeAfter, _nChecksumAfter );
}
return false;
}
void PatchedInfo::AddPatchFileInfo( const std::string & strFileName,
const std::string & strVersion,
const std::string & strSizeBefore,
const std::string & strChecksumBefore,
const std::string & strSizeAfter,
const std::string & strChecksumAfter,
const std::string & strApplicationName,
const std::string & strDirectory,
const std::string & strDescription )
{
PatchFileInfo* pInfo = new PatchFileInfo(
strFileName,
strVersion,
strSizeBefore,
strChecksumBefore,
strSizeAfter,
strChecksumAfter,
strApplicationName,
strDirectory,
strDescription );
m_file_hash.add( pInfo->strFileName, pInfo );
}