Skip to content

Commit

Permalink
disk_interface: De-duplicate RemoveFile on Windows
Browse files Browse the repository at this point in the history
Remove use of `DeleteFileA` and simply fall back to the original
implementation using `remove()` on all platforms.
  • Loading branch information
bradking committed Feb 12, 2021
1 parent 55f48d5 commit 703cfda
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions src/disk_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -275,15 +275,7 @@ int RealDiskInterface::RemoveFile(const string& path) {
// Skip error checking. If this fails, accept whatever happens below.
SetFileAttributesA(path.c_str(), attributes & ~FILE_ATTRIBUTE_READONLY);
}
if (!DeleteFileA(path.c_str())) {
DWORD win_err = GetLastError();
if (win_err == ERROR_FILE_NOT_FOUND || win_err == ERROR_PATH_NOT_FOUND) {
return 1;
}
Error("DeleteFileA(%s): %s", path.c_str(), GetLastErrorString().c_str());
return -1;
}
#else
#endif
if (remove(path.c_str()) < 0) {
switch (errno) {
case ENOENT:
Expand All @@ -293,7 +285,6 @@ int RealDiskInterface::RemoveFile(const string& path) {
return -1;
}
}
#endif
return 0;
}

Expand Down

0 comments on commit 703cfda

Please sign in to comment.