mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-23 10:22:55 +00:00
remove QFile::rename() fallback bits
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
b5bfe3a821
commit
69d2ac47bf
3 changed files with 4 additions and 54 deletions
|
@ -583,49 +583,7 @@ QFile::rename(const QString &newName)
|
|||
d->fileName = newName;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isSequential()) {
|
||||
d->setError(QFile::RenameError, tr("Will not rename sequential file using block copy"));
|
||||
return false;
|
||||
}
|
||||
|
||||
QFile out(newName);
|
||||
if (open(QIODevice::ReadOnly)) {
|
||||
if (out.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
||||
bool error = false;
|
||||
QSTACKARRAY(char, block, QT_BUFFSIZE);
|
||||
qint64 bytes;
|
||||
while ((bytes = read(block, sizeof(block))) > 0) {
|
||||
if (bytes != out.write(block, bytes)) {
|
||||
d->setError(QFile::RenameError, out.errorString());
|
||||
error = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (bytes == -1) {
|
||||
d->setError(QFile::RenameError, errorString());
|
||||
error = true;
|
||||
}
|
||||
if(!error) {
|
||||
if (!remove()) {
|
||||
d->setError(QFile::RenameError, tr("Cannot remove source file"));
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
if (error) {
|
||||
out.remove();
|
||||
} else {
|
||||
d->fileEngine->setFileName(newName);
|
||||
setPermissions(permissions());
|
||||
unsetError();
|
||||
setFileName(newName);
|
||||
}
|
||||
close();
|
||||
return !error;
|
||||
}
|
||||
close();
|
||||
}
|
||||
d->setError(QFile::RenameError, out.isOpen() ? errorString() : out.errorString());
|
||||
d->setError(QFile::RenameError, d->fileEngine->errorString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2021-08-13 19:35+0300\n"
|
||||
"POT-Creation-Date: 2021-08-13 23:30+0300\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -154,15 +154,7 @@ msgstr ""
|
|||
msgid "Destination file exists"
|
||||
msgstr ""
|
||||
|
||||
#: src/core/io/qfile.cpp:588
|
||||
msgid "Will not rename sequential file using block copy"
|
||||
msgstr ""
|
||||
|
||||
#: src/core/io/qfile.cpp:611
|
||||
msgid "Cannot remove source file"
|
||||
msgstr ""
|
||||
|
||||
#: src/core/io/qfile.cpp:1003
|
||||
#: src/core/io/qfile.cpp:961
|
||||
msgid "No file engine available or engine does not support UnMapExtension"
|
||||
msgstr ""
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2021-08-13 19:35+0300\n"
|
||||
"POT-Creation-Date: 2021-08-13 23:30+0300\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
|
Loading…
Add table
Reference in a new issue