fs/FileSystem: RenameFile() throws exception on error
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
@@ -63,18 +63,13 @@ OpenFile(Path file, int flags, int mode)
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* Wrapper for rename() that uses #Path names.
|
||||
*
|
||||
* Throws std::system_error on error.
|
||||
*/
|
||||
static inline bool
|
||||
RenameFile(Path oldpath, Path newpath)
|
||||
{
|
||||
#ifdef WIN32
|
||||
return _trename(oldpath.c_str(), newpath.c_str()) == 0;
|
||||
#else
|
||||
return rename(oldpath.c_str(), newpath.c_str()) == 0;
|
||||
#endif
|
||||
}
|
||||
void
|
||||
RenameFile(Path oldpath, Path newpath);
|
||||
|
||||
#ifndef WIN32
|
||||
|
||||
|
Reference in New Issue
Block a user