Fixed "Build failed".

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-12-19 22:15:42 +02:00
parent 40bf125fdf
commit 95772bf0db

View File

@ -761,30 +761,48 @@ bool VDomDocument::SafeCopy(const QString &source, const QString &destination, Q
qt_ntfs_permission_lookup++; // turn checking on qt_ntfs_permission_lookup++; // turn checking on
#endif /*Q_OS_WIN32*/ #endif /*Q_OS_WIN32*/
QTemporaryFile patternFile(destination + QLatin1Literal(".XXXXXX")); QTemporaryFile destFile(destination + QLatin1Literal(".XXXXXX"));
if (not patternFile.setPermissions(QFile::ReadOwner | QFile::WriteOwner)) destFile.setAutoRemove(false);
if (not destFile.open())
{ {
error = patternFile.errorString(); error = destFile.errorString();
result = false; result = false;
} }
else else
{ {
QFile sourceFile(source); QFile sourceFile(source);
if ( not sourceFile.copy(patternFile.fileName()) ) if (sourceFile.open(QIODevice::ReadOnly))
{ {
error = sourceFile.errorString(); result = true;
result = false; char block[4096];
} qint64 bytes;
else while ((bytes = sourceFile.read(block, sizeof(block))) > 0)
{
if (not patternFile.rename(destination))
{ {
error = patternFile.errorString(); if (bytes != destFile.write(block, bytes))
{
error = destFile.errorString();
result = false;
break;
}
}
if (bytes == -1)
{
error = sourceFile.errorString();
result = false; result = false;
} }
else
if (result)
{ {
result = true; if (not destFile.rename(destination))
{
error = destFile.errorString();
result = false;
}
else
{
result = true;
}
} }
} }
} }