mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-13 10:32:57 +01:00
Added Fix to put Options inside the File Impl Classes
This commit is contained in:
parent
9daaec4ec0
commit
0a9525044d
@ -73,7 +73,7 @@ public:
|
||||
enum Options
|
||||
/// Options for File Copy/Movement
|
||||
{
|
||||
OPT_FAIL_ON_OVERWRITE = 0x01
|
||||
OPT_FAIL_ON_OVERWRITE = OPT_FAIL_ON_OVERWRITE_IMPL
|
||||
};
|
||||
|
||||
File();
|
||||
|
@ -27,6 +27,11 @@ namespace Poco {
|
||||
class FileImpl
|
||||
{
|
||||
protected:
|
||||
|
||||
enum Options {
|
||||
OPT_FAIL_ON_OVERWRITE_IMPL = 0x01
|
||||
};
|
||||
|
||||
typedef UInt64 FileSizeImpl;
|
||||
|
||||
FileImpl();
|
||||
|
@ -28,6 +28,11 @@ namespace Poco {
|
||||
class Foundation_API FileImpl
|
||||
{
|
||||
protected:
|
||||
|
||||
enum Options {
|
||||
OPT_FAIL_ON_OVERWRITE_IMPL = 0x01
|
||||
};
|
||||
|
||||
typedef UInt64 FileSizeImpl;
|
||||
|
||||
FileImpl();
|
||||
|
@ -341,7 +341,7 @@ void FileImpl::copyToImpl(const std::string& path, int options) const
|
||||
}
|
||||
const long blockSize = st.st_blksize;
|
||||
int dd;
|
||||
if (options == 1) {
|
||||
if (options & OPT_FAIL_ON_OVERWRITE_IMPL) {
|
||||
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 && options == 1)
|
||||
if (stat(path.c_str(), &st) == 0 && (options & OPT_FAIL_ON_OVERWRITE_IMPL))
|
||||
throw FileExistsException(path, EEXIST);
|
||||
|
||||
if (rename(_path.c_str(), path.c_str()) != 0)
|
||||
|
@ -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 == 1) == 0)
|
||||
if (CopyFileW(_upath.c_str(), upath.c_str(), (options & OPT_FAIL_ON_OVERWRITE_IMPL) != 0) == 0)
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
|
||||
@ -308,7 +308,7 @@ void FileImpl::renameToImpl(const std::string& path, int options)
|
||||
|
||||
std::wstring upath;
|
||||
convertPath(path, upath);
|
||||
if (options == 1) {
|
||||
if (options & OPT_FAIL_ON_OVERWRITE_IMPL) {
|
||||
if (MoveFileExW(_upath.c_str(), upath.c_str(), NULL) == 0)
|
||||
handleLastErrorImpl(_path);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user