Subversion Repositories spk

Rev

Rev 93 | Rev 121 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 93 Rev 105
Line 36... Line 36...
36
bool COriginalFiles::isOriginal(C_File *f) const
36
bool COriginalFiles::isOriginal(C_File *f) const
37
{
37
{
38
	if ( _getFile(f) )
38
	if ( _getFile(f) )
39
		return true;
39
		return true;
40
	return false;
40
	return false;
-
 
41
}
-
 
42
 
-
 
43
void COriginalFiles::installed(CBaseFile *package)
-
 
44
{
-
 
45
	for ( CListNode<C_File> *oNode = _lFiles.Front(); oNode; oNode = oNode->next() )
-
 
46
	{
-
 
47
		C_File *of = oNode->Data();
-
 
48
		for ( CListNode<C_File> *checkNode = package->GetFileList()->Front(); checkNode; checkNode = checkNode->next() )
-
 
49
		{
-
 
50
			C_File *f = checkNode->Data();
-
 
51
 
-
 
52
			// match the same filetype
-
 
53
			if ( of->GetFileType() != f->GetFileType() )
-
 
54
				continue;
-
 
55
 
-
 
56
			// same file
-
 
57
			if ( of->GetFilename().Compare(f->GetFilename()) )
-
 
58
				_storeOverride(f);
-
 
59
		}
-
 
60
	}
41
}
61
}
42
 
62
 
43
void COriginalFiles::backup(CBaseFile *package, CyStringList *errors)
63
void COriginalFiles::backup(CBaseFile *package, CyStringList *errors)
44
{
64
{
45
	// backup any original files before installing
65
	// backup any original files before installing
Line 75... Line 95...
75
	if ( oDir.Exists(newDir + "/" + f->GetFilename().ToString()) )
95
	if ( oDir.Exists(newDir + "/" + f->GetFilename().ToString()) )
76
		return true;
96
		return true;
77
 
97
 
78
	// make sure the directory exissts
98
	// make sure the directory exissts
79
	if ( !oDir.Exists(newDir) )
99
	if ( !oDir.Exists(newDir) )
80
	{
100
	{
81
		if ( !oDir.Create(newDir) )
101
		if ( !oDir.Create(newDir) )
82
		{
102
		{
83
			CLog::logf(CLog::Log_Install, 2, "Unable to create directory to backup original files, %s", newDir.c_str());
103
			CLog::logf(CLog::Log_Install, 2, "Unable to create directory to backup original files, %s", newDir.c_str());
84
			AddLogEntry(SPKINSTALL_CREATEDIRECTORY_FAIL, newDir, errors);
104
			AddLogEntry(SPKINSTALL_CREATEDIRECTORY_FAIL, newDir, errors);
85
			return false;
105
			return false;
Line 149... Line 169...
149
{
169
{
150
	bool original = false;
170
	bool original = false;
151
 
171
 
152
	// check if its an original file and restore
172
	// check if its an original file and restore
153
	if ( this->isOriginal(f) )
173
	if ( this->isOriginal(f) )
154
	{
174
	{
155
		CFileIO of(_sDir + "/PluginManager/Original/" + f->GetNameDirectory(NULL).ToString());
175
		CFileIO of(_sDir + "/PluginManager/Original/" + f->GetNameDirectory(NULL).ToString());
156
		if ( of.exists() )
176
		if ( of.exists() )
157
		{
177
		{
158
			original = true;
178
			original = true;
159
			if ( of.Rename(_sDir + "/" + f->GetNameDirectory(NULL).ToString()) )
179
			if ( of.Rename(_sDir + "/" + f->GetNameDirectory(NULL).ToString()) )
160
				AddLogEntry(SPKINSTALL_ORIGINAL_RESTORE, f->GetNameDirectory(NULL), errors);
180
				AddLogEntry(SPKINSTALL_ORIGINAL_RESTORE, f->GetNameDirectory(NULL), errors);
161
			else
181
			else
162
				AddLogEntry(SPKINSTALL_ORIGINAL_RESTORE_FAIL, f->GetNameDirectory(NULL), errors);
182
				AddLogEntry(SPKINSTALL_ORIGINAL_RESTORE_FAIL, f->GetNameDirectory(NULL), errors);
-
 
183
 
-
 
184
			CFileIO backupFile(_sDir + "/PluginManager/Original/Replacements/" + f->GetNameDirectory(NULL).ToString());
-
 
185
			if ( backupFile.exists() ) backupFile.remove();
-
 
186
 
163
		}
187
		}
164
	}
188
	}
165
 
189
 
166
	return original;
190
	return original;
167
}
191
}
Line 223... Line 247...
223
			addAny = true;
247
			addAny = true;
224
		}
248
		}
225
	}
249
	}
226
 
250
 
227
	return addAny;
251
	return addAny;
228
}
252
}
229
 
253
 
230
 
254
 
231
void COriginalFiles::reset()
255
void COriginalFiles::reset()
232
{
256
{
233
	_lFiles.MemoryClear();
257
	_lFiles.MemoryClear();
234
}
258
}
Line 336... Line 360...
336
	if ( filetype == FILETYPE_EXTRA )
360
	if ( filetype == FILETYPE_EXTRA )
337
		of->SetDir(searchPath);
361
		of->SetDir(searchPath);
338
	of->SetFilename(_sDir + "/" + of->GetNameDirectory(NULL).ToString());
362
	of->SetFilename(_sDir + "/" + of->GetNameDirectory(NULL).ToString());
339
 
363
 
340
	_lFiles.push_back(of);
364
	_lFiles.push_back(of);
-
 
365
}
-
 
366
 
-
 
367
void COriginalFiles::_storeOverride(C_File *f)
-
 
368
{
-
 
369
	CDirIO oDir(_sDir + "/PluginManager/Original/Replacements");
-
 
370
	if ( !oDir.Exists() ) oDir.Create();
-
 
371
	CFileIO file(oDir.File(f->GetNameDirectory(NULL)));
-
 
372
	if ( !file.GetDirIO().Exists() ) file.GetDirIO().Create();
-
 
373
	CFileIO fromFile(f->GetFilePointer());
-
 
374
	fromFile.copy(file.fullFilename(), true);
341
}
375
}
342
 
376
 
343
}
377
}