コード例 #1
0
void TDirectoryDiffDocument::DoCompareDirectories(TDirectory& directory1, TDirectory& directory2)
{
	directory1.Open();
	directory2.Open();
	
	// iterate through directory 1
	int	count = directory1.GetFileCount();
	for (int i = 0; i < count; i++)
	{
		TString	name;
		bool	isDirectory;
		
		directory1.GetFile(i, name, isDirectory);
		if (isDirectory)
		{
			// ignore CVS, subversion and directories
			if (Tstrcmp(name, "CVS") != 0 && Tstrcmp(name, ".svn") != 0 && Tstrcmp(name, ".git") != 0)
			{
				TDirectory	subDir2(directory2, name);
				
				if (subDir2.Exists())
				{
					TDirectory	subDir1(directory1, name);
					DoCompareDirectories(subDir1, subDir2);
				}
			}
		}
		else
		{
			TFile	file2(directory2, name);
			
			if (file2.Exists())
			{
				TFile	file1(directory1, name);
				
				// ignore class files and compiled python files
				const char* extension = file1.GetFileExtension();
				if (Tstrcmp(extension, "class") != 0 && Tstrcmp(extension, "pyc") != 0)
				{
					if (!TFile::FilesAreEqual(file1, file2, true))
					{
						TString* path = new TString;;
						
						TFile::ComputeRelativePath(file1.GetPath(), fDirectory1.GetPath(), *path);
						fDiffList.InsertLast(path);
					}
				}
			}
		}
	}

	directory1.Close();
	directory2.Close();
}