summaryrefslogtreecommitdiff
path: root/src/utils/physfsrwops.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-08-23 02:27:56 +0300
committerAndrei Karas <akaras@inbox.ru>2013-08-24 21:08:15 +0300
commitd80453b5cbf958084a21e624b1dcd2798f19659a (patch)
treecfba137838d9d3fb51f1b329bc028053b71449a2 /src/utils/physfsrwops.cpp
parentae63e2860fe413649090bcaa4fb5cd322c6f852a (diff)
downloadmv-d80453b5cbf958084a21e624b1dcd2798f19659a.tar.gz
mv-d80453b5cbf958084a21e624b1dcd2798f19659a.tar.bz2
mv-d80453b5cbf958084a21e624b1dcd2798f19659a.tar.xz
mv-d80453b5cbf958084a21e624b1dcd2798f19659a.zip
add support for size attribute in physfsrwops for SDL2.
Diffstat (limited to 'src/utils/physfsrwops.cpp')
-rw-r--r--src/utils/physfsrwops.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/utils/physfsrwops.cpp b/src/utils/physfsrwops.cpp
index 62330f33a..d0560fb1e 100644
--- a/src/utils/physfsrwops.cpp
+++ b/src/utils/physfsrwops.cpp
@@ -151,6 +151,15 @@ static int physfsrwops_close(SDL_RWops *const rw)
return 0;
} /* physfsrwops_close */
+#ifdef USE_SDL2
+static PHYSFSINT physfsrwops_size(SDL_RWops *const rw)
+{
+ PHYSFS_file *const handle = static_cast<PHYSFS_file*>(
+ rw->hidden.unknown.data1);
+ return PHYSFS_fileLength(handle);
+} /* physfsrwops_size */
+#endif
+
static SDL_RWops *create_rwops(PHYSFS_file *const handle)
{
SDL_RWops *retval = nullptr;
@@ -164,6 +173,9 @@ static SDL_RWops *create_rwops(PHYSFS_file *const handle)
retval = SDL_AllocRW();
if (retval)
{
+#ifdef USE_SDL2
+ retval->size = physfsrwops_size;
+#endif
retval->seek = physfsrwops_seek;
retval->read = physfsrwops_read;
retval->write = physfsrwops_write;