コード例 #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();
}
コード例 #2
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");
}
コード例 #3
0
void TestFileUtilMisc(void)
{
	CFileUtil	cFileUtil;
	BOOL		bResult;
	CChars		szPath;

	szPath.Init("TestFileUtil");
	bResult = cFileUtil.MakeDir(szPath.Text());
	AssertTrue(bResult);

	cFileUtil.AppendToPath(&szPath, "FileOfDoom.Indiana");
	bResult = cFileUtil.Touch(szPath.Text());
	AssertTrue(bResult);

	bResult = cFileUtil.Exists(szPath.Text());
	AssertTrue(bResult);

	cFileUtil.RemoveLastFromPath(&szPath);
	cFileUtil.AppendToPath(&szPath, "AnotherDir");
	bResult = cFileUtil.MakeDir(szPath.Text());
	AssertTrue(bResult);

	cFileUtil.RemoveLastFromPath(&szPath);
	cFileUtil.AppendToPath(&szPath, "Master.Chief");
	bResult = cFileUtil.Touch(szPath.Text());
	AssertTrue(bResult);

	bResult = cFileUtil.Delete(szPath.Text());
	AssertTrue(bResult);

	bResult = cFileUtil.Exists(szPath.Text());
	AssertFalse(bResult);

	cFileUtil.RemoveLastFromPath(&szPath);
	cFileUtil.RemoveDir(szPath.Text());
}