1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

Unbreak VC++ build.

llvm-svn: 35751
This commit is contained in:
Jeff Cohen 2007-04-07 20:47:27 +00:00
parent 8fd39019e0
commit d40c15afaa
2 changed files with 32 additions and 32 deletions

View File

@ -368,11 +368,15 @@ bool Path::makeExecutableOnDisk(std::string* ErrMsg) {
bool bool
Path::getDirectoryContents(std::set<Path>& result, std::string* ErrMsg) const { Path::getDirectoryContents(std::set<Path>& result, std::string* ErrMsg) const {
const FileStatus *Status = getFileStatus(false, ErrMsg); WIN32_FILE_ATTRIBUTE_DATA fi;
if (!Status) if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, &fi)) {
MakeErrMsg(ErrMsg, path + ": can't get status of file");
return true; return true;
if (!Status->isDir) { }
MakeErrMsg(ErrMsg, path + ": not a directory");
if (!(fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
if (ErrMsg)
*ErrMsg = path + ": not a directory";
return true; return true;
} }
@ -565,28 +569,11 @@ Path::createFileOnDisk(std::string* ErrMsg) {
bool bool
Path::eraseFromDisk(bool remove_contents, std::string *ErrStr) const { Path::eraseFromDisk(bool remove_contents, std::string *ErrStr) const {
const FileStatus *Status = getFileStatus(false, ErrStr); WIN32_FILE_ATTRIBUTE_DATA fi;
if (!Status) if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, &fi))
return false; return true;
if (Status->isFile) { if (fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
DWORD attr = GetFileAttributes(path.c_str());
// If it doesn't exist, we're done.
if (attr == INVALID_FILE_ATTRIBUTES)
return false;
// Read-only files cannot be deleted on Windows. Must remove the read-only
// attribute first.
if (attr & FILE_ATTRIBUTE_READONLY) {
if (!SetFileAttributes(path.c_str(), attr & ~FILE_ATTRIBUTE_READONLY))
return MakeErrMsg(ErrStr, path + ": Can't destroy file: ");
}
if (!DeleteFile(path.c_str()))
return MakeErrMsg(ErrStr, path + ": Can't destroy file: ");
return false;
} else if (Status->isDir) {
// If it doesn't exist, we're done. // If it doesn't exist, we're done.
if (!exists()) if (!exists())
return false; return false;
@ -645,9 +632,19 @@ Path::eraseFromDisk(bool remove_contents, std::string *ErrStr) const {
return MakeErrMsg(ErrStr, return MakeErrMsg(ErrStr,
std::string(pathname) + ": Can't destroy directory: "); std::string(pathname) + ": Can't destroy directory: ");
return false; return false;
} } else {
// It appears the path doesn't exist. // Read-only files cannot be deleted on Windows. Must remove the read-only
return true; // attribute first.
if (fi.dwFileAttributes & FILE_ATTRIBUTE_READONLY) {
if (!SetFileAttributes(path.c_str(),
fi.dwFileAttributes & ~FILE_ATTRIBUTE_READONLY))
return MakeErrMsg(ErrStr, path + ": Can't destroy file: ");
}
if (!DeleteFile(path.c_str()))
return MakeErrMsg(ErrStr, path + ": Can't destroy file: ");
return false;
}
} }
bool Path::getMagicNumber(std::string& Magic, unsigned len) const { bool Path::getMagicNumber(std::string& Magic, unsigned len) const {

View File

@ -101,12 +101,15 @@ bool sys::RemoveFileOnSignal(const sys::Path &Filename, std::string* ErrMsg) {
// RemoveDirectoryOnSignal - The public API // RemoveDirectoryOnSignal - The public API
bool sys::RemoveDirectoryOnSignal(const sys::Path& path, std::string* ErrMsg) { bool sys::RemoveDirectoryOnSignal(const sys::Path& path, std::string* ErrMsg) {
// Not a directory? // Not a directory?
const sys::FileStatus *Status = path.getFileStatus(false, ErrMsg); WIN32_FILE_ATTRIBUTE_DATA fi;
if (!Status) if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, &fi)) {
MakeErrMsg(ErrMsg, path.toString() + ": can't get status of file");
return true; return true;
if (!Status->isDir) { }
if (!(fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
if (ErrMsg) if (ErrMsg)
*ErrMsg = path.toString() + " is not a directory"; *ErrMsg = path.toString() + ": not a directory";
return true; return true;
} }