fs/FileSystem: RemoveFile() throws exception on error

This commit is contained in:
Max Kellermann
2016-08-15 22:25:15 +02:00
parent 14d3da0e18
commit ea0e6d9824
8 changed files with 48 additions and 22 deletions

View File

@@ -66,3 +66,15 @@ TruncateFile(Path path)
close(fd);
#endif
}
void
RemoveFile(Path path)
{
#ifdef WIN32
if (!DeleteFile(path.c_str()))
throw FormatLastError("Failed to delete %s", path.c_str());
#else
if (unlink(path.c_str()) < 0)
throw FormatErrno("Failed to delete %s", path.c_str());
#endif
}