From 7e06aebf66f8b3e650c2d67ea36889ff35c5abd0 Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Sun, 7 Aug 2011 18:23:07 +0200 Subject: [PATCH] Work around PhysicsFS eof bug on windows (issue #272) --- src/modules/filesystem/physfs/File.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/modules/filesystem/physfs/File.cpp b/src/modules/filesystem/physfs/File.cpp index 0bb77e5d0..dbb0df43d 100644 --- a/src/modules/filesystem/physfs/File.cpp +++ b/src/modules/filesystem/physfs/File.cpp @@ -168,9 +168,23 @@ namespace physfs return write(data->getData(), (size == ALL) ? data->getSize() : size); } +#ifdef LOVE_WINDOWS + inline bool test_eof(File * this, PHYSFS_File *) + { + int pos = this->tell(); + int size = this->getSize(); + return pos == -1 || size == -1 || pos >= size; + } +#else + inline bool test_eof(File *, PHYSFS_File * file) + { + return PHYSFS_eof(file); + } +#endif + bool File::eof() { - if(file == 0 || PHYSFS_eof(file)) + if(file == 0 || test_eof(this, file)) return true; return false; }