Clean up some hacky love.filesystem code.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2019-12-19 17:47:46 -04:00
parent acf84349a9
commit d9ec1d8aa4
3 changed files with 7 additions and 11 deletions
+7 -3
View File
@@ -32,11 +32,15 @@ namespace love
namespace filesystem
{
extern bool hack_setupWriteDirectory();
namespace physfs
{
static bool setupWriteDirectory()
{
auto fs = Module::getInstance<love::filesystem::Filesystem>(Module::M_FILESYSTEM);
return fs != nullptr && fs->setupWriteDirectory();
}
File::File(const std::string &filename)
: filename(filename)
, file(nullptr)
@@ -65,7 +69,7 @@ bool File::open(Mode mode)
throw love::Exception("Could not open file %s. Does not exist.", filename.c_str());
// Check whether the write directory is set.
if ((mode == MODE_APPEND || mode == MODE_WRITE) && (PHYSFS_getWriteDir() == nullptr) && !hack_setupWriteDirectory())
if ((mode == MODE_APPEND || mode == MODE_WRITE) && (PHYSFS_getWriteDir() == nullptr) && !setupWriteDirectory())
throw love::Exception("Could not set write directory.");
// File already open?