mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-13 02:22:57 +01:00
Merge pull request #664 from cryptoknight/WriteOnCopy
Don't automatically make copied files writable on Windows
This commit is contained in:
commit
4e6fad87dc
@ -288,12 +288,8 @@ void FileImpl::copyToImpl(const std::string& path) const
|
||||
{
|
||||
poco_assert (!_path.empty());
|
||||
|
||||
if (CopyFileA(_path.c_str(), path.c_str(), FALSE) != 0)
|
||||
{
|
||||
FileImpl copy(path);
|
||||
copy.setWriteableImpl(true);
|
||||
}
|
||||
else handleLastErrorImpl(_path);
|
||||
if (CopyFileA(_path.c_str(), path.c_str(), FALSE) == 0)
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
|
||||
|
||||
|
@ -294,12 +294,8 @@ void FileImpl::copyToImpl(const std::string& path) const
|
||||
|
||||
std::wstring upath;
|
||||
UnicodeConverter::toUTF16(path, upath);
|
||||
if (CopyFileW(_upath.c_str(), upath.c_str(), FALSE) != 0)
|
||||
{
|
||||
FileImpl copy(path);
|
||||
copy.setWriteableImpl(true);
|
||||
}
|
||||
else handleLastErrorImpl(_path);
|
||||
if (CopyFileW(_upath.c_str(), upath.c_str(), FALSE) == 0)
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
|
||||
|
||||
|
@ -285,12 +285,8 @@ void FileImpl::copyToImpl(const std::string& path) const
|
||||
|
||||
std::wstring upath;
|
||||
UnicodeConverter::toUTF16(path, upath);
|
||||
if (CopyFileW(_upath.c_str(), upath.c_str(), FALSE) != 0)
|
||||
{
|
||||
FileImpl copy(path);
|
||||
copy.setWriteableImpl(true);
|
||||
}
|
||||
else handleLastErrorImpl(_path);
|
||||
if (CopyFileW(_upath.c_str(), upath.c_str(), FALSE) == 0)
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
|
||||
|
||||
|
@ -372,9 +372,11 @@ void FileTest::testCopy()
|
||||
|
||||
File f1("testfile.dat");
|
||||
TemporaryFile f2;
|
||||
f1.copyTo(f2.path());
|
||||
f1.setReadOnly().copyTo(f2.path());
|
||||
assert (f2.exists());
|
||||
assert (!f2.canWrite());
|
||||
assert (f1.getSize() == f2.getSize());
|
||||
f1.setWriteable().remove();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user