mirror of
https://github.com/pocoproject/poco.git
synced 2025-07-01 08:23:29 +02:00
Merge branch 'feature/FileFailOnOverwrite' of https://github.com/KevDi/poco into feature/FileFailOnOverwrite
This commit is contained in:
commit
3424ee7bc8
@ -384,6 +384,11 @@ void FileImpl::renameToImpl(const std::string& path, int options)
|
|||||||
{
|
{
|
||||||
poco_assert (!_path.empty());
|
poco_assert (!_path.empty());
|
||||||
|
|
||||||
|
struct stat st;
|
||||||
|
|
||||||
|
if (stat(path.c_str(), &st) == 0 && failOnOverwrite)
|
||||||
|
throw FileExistsException(path, EEXIST);
|
||||||
|
|
||||||
if (rename(_path.c_str(), path.c_str()) != 0)
|
if (rename(_path.c_str(), path.c_str()) != 0)
|
||||||
handleLastErrorImpl(_path);
|
handleLastErrorImpl(_path);
|
||||||
}
|
}
|
||||||
|
@ -286,6 +286,11 @@ void FileImpl::renameToImpl(const std::string& path, int options)
|
|||||||
{
|
{
|
||||||
poco_assert (!_path.empty());
|
poco_assert (!_path.empty());
|
||||||
|
|
||||||
|
struct stat st;
|
||||||
|
|
||||||
|
if (stat(path.c_str(), &st) == 0 && failOnOverwrite)
|
||||||
|
throw FileExistsException(path, EEXIST);
|
||||||
|
|
||||||
if (rename(_path.c_str(), path.c_str()) != 0)
|
if (rename(_path.c_str(), path.c_str()) != 0)
|
||||||
handleLastErrorImpl(_path);
|
handleLastErrorImpl(_path);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user