From 94c8be709d385e756457f9ecd3559cc9502a0deb Mon Sep 17 00:00:00 2001 From: Jonne Nauha Date: Thu, 3 Oct 2013 15:58:24 +0300 Subject: [PATCH] LoadFileToVector: Fix a bug that empty file size was an error case. If the file is found but the contents is empty we return true but log a warning as this is a unusual situation. Add a single space to data/assets/dummy.txt so it wont spam these warnings on the local storage roaming step when tundra is ran. --- bin/data/assets/dummy.txt | 1 + src/Core/TundraCore/Asset/AssetAPI.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/bin/data/assets/dummy.txt b/bin/data/assets/dummy.txt index e69de29bb2..0519ecba6e 100644 --- a/bin/data/assets/dummy.txt +++ b/bin/data/assets/dummy.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/Core/TundraCore/Asset/AssetAPI.cpp b/src/Core/TundraCore/Asset/AssetAPI.cpp index 498d890643..6933d630e2 100644 --- a/src/Core/TundraCore/Asset/AssetAPI.cpp +++ b/src/Core/TundraCore/Asset/AssetAPI.cpp @@ -2304,16 +2304,18 @@ bool LoadFileToVector(const QString &filename, std::vector &dst) qint64 fileSize = file.size(); if (fileSize <= 0) { - LogError("AssetAPI::LoadFileToVector: Failed to read file '" + filename + "' of " + fileSize + " bytes in size."); + // If the file size is 0 this is still considered a success. + // Log out a warning for it either way as this is an unusual case. + LogWarning(QString("AssetAPI::LoadFileToVector: Source file '%1' exists but size is 0. Reading is reported to be successfull but read data is empty!").arg(filename)); file.close(); - return false; + return true; } dst.resize(fileSize); qint64 numRead = file.read((char*)&dst[0], fileSize); file.close(); if (numRead < fileSize) { - LogError("AssetAPI::LoadFileToVector: Failed to read " + QString::number(numRead) + " bytes from file '" + filename + "'."); + LogError(QString("AssetAPI::LoadFileToVector: Failed to read full %1 bytes from file '%2', instead read %3 bytes.").arg(fileSize).arg(filename).arg(numRead)); return false; } return true;