Skip to content
Snippets Groups Projects

Using qint64 to Check Written Data

Merged Karel Slaný requested to merge file-write-modification into develop
Compare and
1 file
+ 4
4
Preferences
Compare changes
+ 4
4
@@ -300,7 +300,7 @@ QString writeFile(const QString &filePath, const QString &fileName,
QFile fout(nonconflictingFileName(filePath + QDir::separator()
+ nameCopy));
if (!fout.open(QIODevice::WriteOnly)) {
if (Q_UNLIKELY(!fout.open(QIODevice::WriteOnly))) {
logErrorNL("Cannot open file '%s'.",
nameCopy.toUtf8().constData());
return QString();
@@ -308,11 +308,11 @@ QString writeFile(const QString &filePath, const QString &fileName,
/* Get whole path. */
QString fullName = fout.fileName();
int written = fout.write(data);
qint64 written = fout.write(data);
bool flushed = fout.flush();
fout.close();
if ((written != data.size()) || !flushed) {
if (Q_UNLIKELY((written != data.size()) || !flushed)) {
if (deleteOnError) {
QFile::remove(fullName);
}
@@ -528,7 +528,7 @@ bool writeZfoToLocalStorage(const QString &username, bool testing,
bool flushed = fout.flush();
fout.close();
if ((written != zfoData.size()) || !flushed) {
if (Q_UNLIKELY((written != zfoData.size()) || !flushed)) {
QFile::remove(fullName);
return false;
}