mirror of
https://github.com/pocoproject/poco.git
synced 2025-05-29 23:42:39 +02: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
|
enum Options
|
||||||
/// Options for File Copy/Movement
|
/// Options for File Copy/Movement
|
||||||
{
|
{
|
||||||
OPT_FAIL_ON_OVERWRITE = 0x01
|
OPT_FAIL_ON_OVERWRITE = OPT_FAIL_ON_OVERWRITE_IMPL
|
||||||
};
|
};
|
||||||
|
|
||||||
File();
|
File();
|
||||||
|
@ -27,6 +27,11 @@ namespace Poco {
|
|||||||
class FileImpl
|
class FileImpl
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
enum Options {
|
||||||
|
OPT_FAIL_ON_OVERWRITE_IMPL = 0x01
|
||||||
|
};
|
||||||
|
|
||||||
typedef UInt64 FileSizeImpl;
|
typedef UInt64 FileSizeImpl;
|
||||||
|
|
||||||
FileImpl();
|
FileImpl();
|
||||||
|
@ -28,6 +28,11 @@ namespace Poco {
|
|||||||
class Foundation_API FileImpl
|
class Foundation_API FileImpl
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
enum Options {
|
||||||
|
OPT_FAIL_ON_OVERWRITE_IMPL = 0x01
|
||||||
|
};
|
||||||
|
|
||||||
typedef UInt64 FileSizeImpl;
|
typedef UInt64 FileSizeImpl;
|
||||||
|
|
||||||
FileImpl();
|
FileImpl();
|
||||||
|
@ -341,7 +341,7 @@ void FileImpl::copyToImpl(const std::string& path, int options) const
|
|||||||
}
|
}
|
||||||
const long blockSize = st.st_blksize;
|
const long blockSize = st.st_blksize;
|
||||||
int dd;
|
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);
|
dd = open(path.c_str(), O_CREAT | O_TRUNC | O_EXCL | O_WRONLY, st.st_mode);
|
||||||
} else {
|
} else {
|
||||||
dd = open(path.c_str(), O_CREAT | O_TRUNC | O_WRONLY, st.st_mode);
|
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;
|
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);
|
throw FileExistsException(path, EEXIST);
|
||||||
|
|
||||||
if (rename(_path.c_str(), path.c_str()) != 0)
|
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;
|
std::wstring upath;
|
||||||
convertPath(path, 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);
|
handleLastErrorImpl(_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,7 +308,7 @@ void FileImpl::renameToImpl(const std::string& path, int options)
|
|||||||
|
|
||||||
std::wstring upath;
|
std::wstring upath;
|
||||||
convertPath(path, upath);
|
convertPath(path, upath);
|
||||||
if (options == 1) {
|
if (options & OPT_FAIL_ON_OVERWRITE_IMPL) {
|
||||||
if (MoveFileExW(_upath.c_str(), upath.c_str(), NULL) == 0)
|
if (MoveFileExW(_upath.c_str(), upath.c_str(), NULL) == 0)
|
||||||
handleLastErrorImpl(_path);
|
handleLastErrorImpl(_path);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user