Skip to content

Commit

Permalink
Filesystem: Actually throw ENOENT for missing files
Browse files Browse the repository at this point in the history
  • Loading branch information
mook committed Oct 30, 2015
1 parent 7bf6eca commit 32a4a79
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,27 @@ void FileSystem::openReadRaw(SDL_RWops &ops,
bool freeOnClose)
{
PHYSFS_File *handle = PHYSFS_openRead(filename);
assert(handle);

if (!handle)
{
PHYSFS_ErrorCode error = PHYSFS_getLastErrorCode();
switch (error)
{
case PHYSFS_ERR_NOT_MOUNTED:
case PHYSFS_ERR_NOT_FOUND:
case PHYSFS_ERR_BAD_FILENAME:
throw Exception(Exception::NoFileError, "%s", filename);
case PHYSFS_ERR_PAST_EOF:
case PHYSFS_ERR_NOT_A_FILE:
case PHYSFS_ERR_IO:
throw Exception(Exception::IOError, "%s", filename);
case PHYSFS_ERR_INVALID_ARGUMENT:
throw Exception(Exception::ArgumentError, "%s", filename);
default:
throw Exception(Exception::PHYSFSError,
"PhysFS: %s", PHYSFS_getErrorByCode(error));
}
}

initReadOps(handle, ops, freeOnClose);
}
Expand Down

0 comments on commit 32a4a79

Please sign in to comment.