diff options
Diffstat (limited to 'src/fs/virtfs/virtfsdirrwops.cpp')
-rw-r--r-- | src/fs/virtfs/virtfsdirrwops.cpp | 17 |
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 |