Avoid hard crashes when calling love.filesystem functions if love.filesystem.init was never called.

This only applies when liblove is used directly, as love.filesystem.init is called automatically when the love executable starts up.
This commit is contained in:
Alex Szpakowski
2015-12-24 22:53:48 -05:00
parent 67fe29b30e
commit b56a0cfc3d
2 changed files with 41 additions and 0 deletions
+3
View File
@@ -57,6 +57,9 @@ bool File::open(Mode mode)
if (mode == MODE_CLOSED)
return true;
if (!PHYSFS_isInit())
throw love::Exception("PhysFS is not initialized.");
// File must exist if read mode.
if ((mode == MODE_READ) && !PHYSFS_exists(filename.c_str()))
throw love::Exception("Could not open file %s. Does not exist.", filename.c_str());