summaryrefslogtreecommitdiff
path: root/src/fs/virtfs
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-03-30 03:06:37 +0300
committerAndrei Karas <akaras@inbox.ru>2017-03-30 03:07:24 +0300
commitf8120f4c08f8b99d781c0a310ce1c0e383b256ae (patch)
tree5a2e125877879a66ea7364fdc93e4e1e2f5243ee /src/fs/virtfs
parent1ca6f9ef6e0b4895976f2de5199519afd327ac8b (diff)
downloadmanaverse-f8120f4c08f8b99d781c0a310ce1c0e383b256ae.tar.gz
manaverse-f8120f4c08f8b99d781c0a310ce1c0e383b256ae.tar.bz2
manaverse-f8120f4c08f8b99d781c0a310ce1c0e383b256ae.tar.xz
manaverse-f8120f4c08f8b99d781c0a310ce1c0e383b256ae.zip
Improve VirtFsDir::rwops_size
Diffstat (limited to 'src/fs/virtfs')
-rw-r--r--src/fs/virtfs/virtfsdirrwops.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/fs/virtfs/virtfsdirrwops.cpp b/src/fs/virtfs/virtfsdirrwops.cpp
index 2170dd05f..f5fc3acd1 100644
--- a/src/fs/virtfs/virtfsdirrwops.cpp
+++ b/src/fs/virtfs/virtfsdirrwops.cpp
@@ -230,7 +230,22 @@ namespace VirtFsDir
{
VirtFile *const handle = static_cast<VirtFile *const>(
rw->hidden.unknown.data1);
- return VirtFs::fileLength(handle);
+ FILEHTYPE fd = handle->mFd;
+#ifdef USE_FILE_FOPEN
+ const long pos = ftell(fd);
+ fseek(fd, 0, SEEK_END);
+ const long sz = ftell(fd);
+ fseek(fd, pos, SEEK_SET);
+ return sz;
+#else // USE_FILE_FOPEN
+ struct stat statbuf;
+ if (fstat(fd, &statbuf) == -1)
+ {
+ reportAlways("VirtFsDir::fileLength error.");
+ return -1;
+ }
+ return static_cast<int64_t>(statbuf.st_size);
+#endif // USE_FILE_FOPEN
}
#endif // USE_SDL2