diff --git a/Foundation/include/Poco/File.h b/Foundation/include/Poco/File.h index 30fbfe564..7014dc03f 100644 --- a/Foundation/include/Poco/File.h +++ b/Foundation/include/Poco/File.h @@ -194,18 +194,18 @@ public: /// The target path can be a directory. /// /// A directory is copied recursively. - /// If failOnOverwrite is set the Method throws an FileExists Exception + /// If options is set to OPT_FAIL_ON_OVERWRITE the Method throws an FileExists Exception /// if the File already exists. void moveTo(const std::string& path, int options = 0); /// Copies the file (or directory) to the given path and /// removes the original file. The target path can be a directory. - /// If failOnOverwrite is set the Method throws an FileExists Exception + /// If options is set to OPT_FAIL_ON_OVERWRITE the Method throws an FileExists Exception /// if the File already exists. void renameTo(const std::string& path, int options = 0); /// Renames the file to the new name. - /// If failOnOverwrite is set the Method throws an FileExists Exception + /// If options is set to OPT_FAIL_ON_OVERWRITE the Method throws an FileExists Exception /// if the File already exists. void linkTo(const std::string& path, LinkType type = LINK_SYMBOLIC) const; diff --git a/Foundation/src/File_UNIX.cpp b/Foundation/src/File_UNIX.cpp index a1ff9d1f1..f6cdf754f 100644 --- a/Foundation/src/File_UNIX.cpp +++ b/Foundation/src/File_UNIX.cpp @@ -341,7 +341,7 @@ void FileImpl::copyToImpl(const std::string& path, int options) const } const long blockSize = st.st_blksize; int dd; - if (options) { + if (options == 1) { dd = open(path.c_str(), O_CREAT | O_TRUNC | O_EXCL | O_WRONLY, st.st_mode); } else { dd = open(path.c_str(), O_CREAT | O_TRUNC | O_WRONLY, st.st_mode); @@ -386,7 +386,7 @@ void FileImpl::renameToImpl(const std::string& path, int options) struct stat st; - if (stat(path.c_str(), &st) == 0 && failOnOverwrite) + if (stat(path.c_str(), &st) == 0 && options == 1) 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 699aca51b..c7bb2ba54 100644 --- a/Foundation/src/File_VX.cpp +++ b/Foundation/src/File_VX.cpp @@ -248,7 +248,7 @@ void FileImpl::copyToImpl(const std::string& path, int options) const const long blockSize = st.st_blksize; int dd; - if (options) { + if (options == 1) { dd = open(path.c_str(), O_CREAT | O_TRUNC | O_EXCL | O_WRONLY, st.st_mode & S_IRWXU); } else { dd = open(path.c_str(), O_CREAT | O_TRUNC | O_WRONLY, st.st_mode & S_IRWXU); @@ -288,7 +288,7 @@ void FileImpl::renameToImpl(const std::string& path, int options) struct stat st; - if (stat(path.c_str(), &st) == 0 && failOnOverwrite) + if (stat(path.c_str(), &st) == 0 && options == 1) throw FileExistsException(path, EEXIST); if (rename(_path.c_str(), path.c_str()) != 0) diff --git a/Foundation/src/File_WIN32.cpp b/Foundation/src/File_WIN32.cpp index b70072cf4..429ed2e6f 100644 --- a/Foundation/src/File_WIN32.cpp +++ b/Foundation/src/File_WIN32.cpp @@ -292,7 +292,7 @@ void FileImpl::copyToImpl(const std::string& path, int options) const { poco_assert (!_path.empty()); - if (CopyFileA(_path.c_str(), path.c_str(), options) == 0) + if (CopyFileA(_path.c_str(), path.c_str(), options == 1) == 0) handleLastErrorImpl(_path); } @@ -301,7 +301,7 @@ void FileImpl::renameToImpl(const std::string& path, int options) { poco_assert (!_path.empty()); - if (options) { + if (options == 1) { if (MoveFileExA(_path.c_str(), path.c_str(), NULL) == 0) handleLastErrorImpl(_path); } else { diff --git a/Foundation/src/File_WIN32U.cpp b/Foundation/src/File_WIN32U.cpp index 6dc46e9de..92c3c2562 100644 --- a/Foundation/src/File_WIN32U.cpp +++ b/Foundation/src/File_WIN32U.cpp @@ -297,7 +297,7 @@ void FileImpl::copyToImpl(const std::string& path, int options) const std::wstring upath; convertPath(path, upath); - if (CopyFileW(_upath.c_str(), upath.c_str(), options) == 0) + if (CopyFileW(_upath.c_str(), upath.c_str(), options == 1) == 0) handleLastErrorImpl(_path); } @@ -308,7 +308,7 @@ void FileImpl::renameToImpl(const std::string& path, int options) std::wstring upath; convertPath(path, upath); - if (options) { + if (options == 1) { if (MoveFileExW(_upath.c_str(), upath.c_str(), NULL) == 0) handleLastErrorImpl(_path); } else {