Don't unnecessarily die when loading empty files

This was SVN commit r11449.
This commit is contained in:
Ykkrosh 2012-04-07 21:36:27 +00:00
parent 6b5034e313
commit b253cbbee6
2 changed files with 3 additions and 9 deletions

View File

@ -96,6 +96,7 @@ Status ReloadChangedFiles()
CVFSFile::CVFSFile()
: m_BufferSize(0)
{
}
@ -116,6 +117,8 @@ PSRETURN CVFSFile::Load(const PIVFS& vfs, const VfsPath& filename)
if (ret != INFO::OK)
{
LOGERROR(L"CVFSFile: file %ls couldn't be opened (vfs_load: %lld)", filename.string().c_str(), (long long)ret);
m_Buffer.reset();
m_BufferSize = 0;
return PSRETURN_CVFSFile_LoadFailed;
}
@ -124,14 +127,6 @@ PSRETURN CVFSFile::Load(const PIVFS& vfs, const VfsPath& filename)
const u8* CVFSFile::GetBuffer() const
{
// Die in a very obvious way, to avoid subtle problems caused by
// accidentally forgetting to check that the open succeeded
if (!m_Buffer)
{
debug_warn(L"GetBuffer() called with no file loaded");
throw PSERROR_CVFSFile_InvalidBufferAccess();
}
return m_Buffer.get();
}

View File

@ -57,7 +57,6 @@ extern Status ReloadChangedFiles();
ERROR_GROUP(CVFSFile);
ERROR_TYPE(CVFSFile, LoadFailed);
ERROR_TYPE(CVFSFile, AlreadyLoaded);
ERROR_TYPE(CVFSFile, InvalidBufferAccess);
// Reads a file, then gives read-only access to the contents
class CVFSFile