fs/FileSystem: RenameFile() throws exception on error

This commit is contained in:
Max Kellermann
2016-12-04 19:59:33 +01:00
parent dee6e498d9
commit 6caf53d1c2
3 changed files with 27 additions and 30 deletions

View File

@@ -26,6 +26,19 @@
#include <errno.h>
#include <fcntl.h>
void
RenameFile(Path oldpath, Path newpath)
{
#ifdef WIN32
if (!MoveFileEx(oldpath.c_str(), newpath.c_str(),
MOVEFILE_REPLACE_EXISTING))
throw MakeLastError("Failed to rename file");
#else
if (rename(oldpath.c_str(), newpath.c_str()) < 0)
throw MakeErrno("Failed to rename file");
#endif
}
AllocatedPath
ReadLink(Path path)
{