Updated Comments and fixed bug within the Unix File Implementation

This commit is contained in:
Jan Kevin Dick
2019-11-26 14:10:32 +01:00
parent 3424ee7bc8
commit 9daaec4ec0
5 changed files with 11 additions and 11 deletions

View File

@@ -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;

View File

@@ -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)

View File

@@ -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)

View File

@@ -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 {

View File

@@ -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 {