Esempio n. 1
0
void TestFileUtilTouchDirectory(void)
{
	CFileUtil		cFileUtil;
	CChars			szDirectory;
	CChars			szFileName;

	cFileUtil.RemoveDir("file_util");

	szDirectory.Init("file_util" _FS_ "directory" _FS_ "make" _FS_ "test");
	cFileUtil.FullPath(&szDirectory);
	szFileName.Init(szDirectory);
	cFileUtil.AppendToPath(&szFileName, "Warthog.PIG");
	AssertTrue(cFileUtil.TouchDir(szFileName.Text()));
	AssertTrue(cFileUtil.Touch(szFileName.Text()));

	szDirectory.Kill();
	szFileName.Kill();

	cFileUtil.RemoveDir("file_util");

	AssertFalse(cFileUtil.TouchDir("C:\\Warthog.PIG"));
	AssertFalse(cFileUtil.TouchDir("\\Warthog.PIG"));

	szDirectory.Init();
	cFileUtil.CurrentDirectory(&szDirectory);
	szDirectory.Append("War-pig.hog");
	AssertFalse(cFileUtil.TouchDir(szDirectory.Text()));
	szDirectory.Kill();
}
void TestObjectsFlushNoClear(void)
{
	CFileUtil	cFileUtil;
	BOOL		bResult;

	cFileUtil.RemoveDir("Output");
	cFileUtil.MakeDir("Output/Flush1");
	ObjectsInit("Output/Flush1");
	SetupObjectsForDehollowfication();

	AssertLongLongInt(0, gcObjects.NumDatabaseObjects());
	AssertLongLongInt(0, gcObjects.NumDatabaseNames());
	AssertLongLongInt(9, gcObjects.NumMemoryIndexes());
	AssertLongLongInt(6, gcObjects.NumMemoryNames());
	
	bResult = gcObjects.Flush(FALSE, FALSE);
	AssertTrue(bResult);

	AssertLongLongInt(9, gcObjects.NumDatabaseObjects());
	AssertLongLongInt(6, gcObjects.NumDatabaseNames());
	AssertLongLongInt(9, gcObjects.NumMemoryIndexes());
	AssertLongLongInt(6, gcObjects.NumMemoryNames());

	ObjectsKill();

	CArrayChars	aszFileNames;
	int				i;
	CChars*			psz;
	CChars			szOutput;
	CChars			szFileName;

	aszFileNames.Init();
	cFileUtil.FindAllFiles("Input/Dehollowfication", &aszFileNames, FALSE, FALSE);

	for (i = 0; i < aszFileNames.NumElements(); i++)
	{
		psz = aszFileNames.Get(i);
		
		szFileName.Init(psz->Text());
		cFileUtil.RemovePath(&szFileName);
		szOutput.Init();
		cFileUtil.CurrentDirectory(&szOutput);
		cFileUtil.AppendToPath(&szOutput, "Output/Flush1");
		cFileUtil.AppendToPath(&szOutput, szFileName.Text());

		AssertFile(psz->Text(), szOutput.Text());

		szOutput.Kill();
		szFileName.Kill();
	}

	aszFileNames.Kill();
}
Esempio n. 3
0
void TestFileUtilMakeDirectory(void)
{
	CFileUtil		cFileUtil;
	CChars			szDirectory;
	CChars			szFileName;
	CArrayString	aszFiles;
	CChars			szParentDirectory;
	CChars			szCurrentDirectory;
	BOOL			bResult;

	cFileUtil.RemoveDir("file_util");

	szParentDirectory.Init("file_util" _FS_ "directory" _FS_ "make" _FS_ "test");
	szDirectory.Init(szParentDirectory);
	szDirectory.Append(_FS_);
	szDirectory.Append("GABBA");
	szFileName.Init(szDirectory);
	szFileName.Append(_FS_);
	szFileName.Append("FileName.txt");

	bResult = cFileUtil.Touch(szFileName.Text());
	AssertFalse(bResult);

	cFileUtil.MakeDir(szDirectory.Text());

	szCurrentDirectory.Init();
	cFileUtil.CurrentDirectory(&szCurrentDirectory);
	szCurrentDirectory.Append(_FS_);
	szCurrentDirectory.Append(szDirectory);

	aszFiles.Init(1);
	cFileUtil.FindAllDirectories(szParentDirectory.Text(), &aszFiles, FALSE);
	AssertInt(1, aszFiles.NumElements());
	AssertString(szCurrentDirectory.Text(), aszFiles.GetText(0));

	bResult = cFileUtil.Touch(szFileName.Text());
	AssertTrue(bResult);

	szParentDirectory.Kill();
	szDirectory.Kill();
	szFileName.Kill();

	cFileUtil.RemoveDir("file_util");
}