コード例 #1
0
UINT64 CDirectory::Size()
{
    #ifdef WIN32

	UINT64 ui64Size = 0;

	CVector<CString> Directories;
	CVector<CString> Files;

	if (!this->Read(&Files, &Directories))
	{
		Directories.AllDelete();
		Files.AllDelete();

		SCFError(ErrorDirectoryFailedSizeGet);
		return (UINT64)-1;
	}

	for (UINT i = 0; i < Files.Size(); i++)
	{
		ui64Size += CFile(this->PathFull() + (CString&)(Files[i])).Size();
	}

	for (UINT i = 0; i < Directories.Size(); i++)
	{
		ui64Size += CDirectory(this->PathFull() + (CString&)(Directories[i]) + STRING("\\")).Size();
	}

	Directories.AllDelete();
	Files.AllDelete();

	return ui64Size;

	#else

    //TODO:
    return -1;

	#endif // WIN32
}
コード例 #2
0
bool CDirectory::Erase()
{
	CVector<CString> Directories;
	CVector<CString> Files;

	if (!this->Read(&Files, &Directories))
	{
		Directories.AllDelete();
		Files.AllDelete();

		SCFError(ErrorDirectoryFailedErase);
		return false;
	}

	for (UINT i = 0; i < Files.Size(); i++)
	{
		if (!CFile(this->PathFull() + (CString&)(Files[i])).Delete())
		{
			Directories.AllDelete();
			Files.AllDelete();

			SCFError(ErrorDirectoryFailedErase);
			return false;
		}
	}

	for (UINT i = 0; i < Directories.Size(); i++)
	{
		if (!CDirectory(this->PathFull() + (CString&)(Directories[i]) + STRING("\\")).Delete())
		{
			Directories.AllDelete();
			Files.AllDelete();

			SCFError(ErrorDirectoryFailedErase);
			return false;
		}
	}

	Directories.AllDelete();
	Files.AllDelete();

	return true;
}
コード例 #3
0
bool CDirectory::Copy(_INOUT CDirectory& rSource, _INOUT CDirectory& rDestination, _IN bool bOverwriteExisting)
{
    #ifdef WIN32

	if (!rDestination.Create(bOverwriteExisting))
	{
		SCFError(ErrorDirectoryFailedCopy);
		return false;
	}

	CVector<CString> Directories;
	CVector<CString> Files;

	if (!rSource.Read(&Files, &Directories))
	{
		Directories.AllDelete();
		Files.AllDelete();

		SCFError(ErrorDirectoryFailedCopy);
		return false;
	}

	CString csTerminator(STRING("\\"));

	for (UINT i = 0; i < Directories.Size(); i++)
	{
		CDirectory DirectorySource     (rSource.PathFull()      + (CString&)(Directories[i]) + csTerminator);
		CDirectory DirectoryDestination(rDestination.PathFull() + (CString&)(Directories[i]) + csTerminator);

		if (!Copy(DirectorySource, DirectoryDestination, bOverwriteExisting))
		{
			Directories.AllDelete();
			Files.AllDelete();

			SCFError(ErrorDirectoryFailedCopy);
			return false;
		}
	}

	for (UINT i = 0; i < Files.Size(); i++)
	{
		CFile FileSource     (rSource.PathFull()      + (CString&)(Files[i]));
		CFile FileDestination(rDestination.PathFull() + (CString&)(Files[i]));

		if (!FileSource.Copy(FileDestination, bOverwriteExisting))
		{
			Directories.AllDelete();
			Files.AllDelete();

			SCFError(ErrorDirectoryFailedCopy);
			return false;
		}
	}

	Directories.AllDelete();
	Files.AllDelete();

	return true;

	#else

    //TODO:
    return false;

	#endif // WIN32
}