Subversion Repositories spk

Rev

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

Rev 173 Rev 181
Line 38... Line 38...
38
	return true;
38
	return true;
39
}
39
}
40
 
40
 
41
Utils::String CModDiff::_extractFile(const Utils::String &sFile, const Utils::String &sTo)
41
Utils::String CModDiff::_extractFile(const Utils::String &sFile, const Utils::String &sTo)
42
{
42
{
43
	SInCatFile *c = m_pCatFile->FindData(sFile);
43
	SInCatFile *c = m_pCatFile->findData(sFile);
44
	if ( !c ) c = m_pCatFile->FindData(m_sAddon + "/" + sFile);
44
	if ( !c ) c = m_pCatFile->findData(m_sAddon + "/" + sFile);
45
	if ( !c ) return m_fileSystem.ExtractGameFile(sFile, sTo);
45
	if ( !c ) return m_fileSystem.ExtractGameFile(sFile, sTo);
46
	if ( m_pCatFile->ExtractFile(c, sTo) ) return sTo;
46
	if (m_pCatFile->extractFile(c, sTo)) return sTo;
47
	return "";
47
	return "";
48
}
48
}
49
 
49
 
50
bool CModDiff::doDiff(const Utils::String &sModFile)
50
bool CModDiff::doDiff(const Utils::String &sModFile)
51
{
51
{
52
	// find the file in the loaded cat
52
	// find the file in the loaded cat
53
	SInCatFile *c = m_pCatFile->FindData(sModFile);
53
	SInCatFile *c = m_pCatFile->findData(sModFile);
54
	if ( !c ) c = m_pCatFile->FindData(m_sAddon + "/" + sModFile);
54
	if ( !c ) c = m_pCatFile->findData(m_sAddon + "/" + sModFile);
55
	if ( !c ) return false;
55
	if ( !c ) return false;
56
 
56
 
57
	// extract the matching file
57
	// extract the matching file
58
	Utils::String sToFile = CFileIO(m_sTempDir + "/" + CFileIO(c->sFile).filename()).fullFilename();
58
	Utils::String sToFile = CFileIO(m_sTempDir + "/" + CFileIO(c->sFile).filename()).fullFilename();
59
	if ( !m_pCatFile->ExtractFile(sModFile, sToFile) ) return false;
59
	if ( !m_pCatFile->extractFile(sModFile, sToFile) ) return false;
60
 
60
 
61
	// create a diff
61
	// create a diff
62
	Utils::String to = m_fileSystem.ExtractGameFile(c->sFile, sToFile + ".compare");
62
	Utils::String to = m_fileSystem.ExtractGameFile(c->sFile, sToFile + ".compare");
63
	if ( !to.empty() ) {
63
	if ( !to.empty() ) {
64
		SDiffFile *diff = diffFile(to, sToFile, c->sFile);
64
		SDiffFile *diff = diffFile(to, sToFile, c->sFile);
Line 190... Line 190...
190
		Utils::String checkFile = f->sFile.findReplace("\\", "/");
190
		Utils::String checkFile = f->sFile.findReplace("\\", "/");
191
		if ( (checkFile.left(6).Compare("types/") || checkFile.left(2).Compare("t/") || checkFile.left(6 + addonSize).Compare(addonDir + "/types/") || checkFile.left(2 + addonSize).Compare(addonDir + "/t/")) && _validFile(checkFile) )
191
		if ( (checkFile.left(6).Compare("types/") || checkFile.left(2).Compare("t/") || checkFile.left(6 + addonSize).Compare(addonDir + "/types/") || checkFile.left(2 + addonSize).Compare(addonDir + "/t/")) && _validFile(checkFile) )
192
		{
192
		{
193
			// extract the file to the temp dir
193
			// extract the file to the temp dir
194
			Utils::String toFile = CFileIO(m_sTempDir + "/" + CFileIO(f->sFile).filename()).fullFilename();
194
			Utils::String toFile = CFileIO(m_sTempDir + "/" + CFileIO(f->sFile).filename()).fullFilename();
195
			if ( cat.ExtractFile(f, toFile ) )
195
			if (cat.extractFile(f, toFile ))
196
			{
196
			{
197
				// now extract the matching file from the game dir
197
				// now extract the matching file from the game dir
198
				if ( m_fileSystem.ExtractGameFile(f->sFile, toFile + ".compare") )
198
				if ( m_fileSystem.ExtractGameFile(f->sFile, toFile + ".compare") )
199
				{
199
				{
200
					diffFile(toFile + ".compare", toFile, f->sFile);
200
					diffFile(toFile + ".compare", toFile, f->sFile);
Line 485... Line 485...
485
 
485
 
486
			// now write the file
486
			// now write the file
487
			CFileIO WriteFile(m_sTempDir + "/" + CFileIO(f->sFile).filename());
487
			CFileIO WriteFile(m_sTempDir + "/" + CFileIO(f->sFile).filename());
488
			if ( WriteFile.writeFile(&writeLines) )
488
			if ( WriteFile.writeFile(&writeLines) )
489
			{
489
			{
490
				if ( cat.AppendFile(m_sTempDir + "/" + CFileIO(f->sFile).filename(), f->sFile) )
490
				if ( cat.appendFile(m_sTempDir + "/" + CFileIO(f->sFile).filename(), f->sFile) )
491
				{
-
 
492
					ret = true;
491
					ret = true;
493
				}
-
 
494
				WriteFile.remove();
492
				WriteFile.remove();
495
			}
493
			}
496
		}
494
		}
497
	}
495
	}
498
 
496