diff --git a/Foundation/src/File_UNIX.cpp b/Foundation/src/File_UNIX.cpp index 83f0c9ff4..e44b843d5 100644 --- a/Foundation/src/File_UNIX.cpp +++ b/Foundation/src/File_UNIX.cpp @@ -386,7 +386,7 @@ void FileImpl::renameToImpl(const std::string& path, bool failOnOverwrite) struct stat st; - if (stat(path.c_str(), &st) == 0) + if (stat(path.c_str(), &st) == 0 && failOnOverwrite) throw FileExistsException(path, EEXIST); if (rename(_path.c_str(), path.c_str()) != 0) diff --git a/Foundation/src/File_VX.cpp b/Foundation/src/File_VX.cpp index b6d98748f..f7a8963e1 100644 --- a/Foundation/src/File_VX.cpp +++ b/Foundation/src/File_VX.cpp @@ -288,7 +288,7 @@ void FileImpl::renameToImpl(const std::string& path, bool failOnOverwrite) struct stat st; - if (stat(path.c_str(), &st) == 0) + if (stat(path.c_str(), &st) == 0 && failOnOverwrite) throw FileExistsException(path, EEXIST); if (rename(_path.c_str(), path.c_str()) != 0)