diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-03-30 03:06:37 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-03-30 03:07:24 +0300 |
commit | f8120f4c08f8b99d781c0a310ce1c0e383b256ae (patch) | |
tree | 5a2e125877879a66ea7364fdc93e4e1e2f5243ee /src | |
parent | 1ca6f9ef6e0b4895976f2de5199519afd327ac8b (diff) | |
download | plus-f8120f4c08f8b99d781c0a310ce1c0e383b256ae.tar.gz plus-f8120f4c08f8b99d781c0a310ce1c0e383b256ae.tar.bz2 plus-f8120f4c08f8b99d781c0a310ce1c0e383b256ae.tar.xz plus-f8120f4c08f8b99d781c0a310ce1c0e383b256ae.zip |
Improve VirtFsDir::rwops_size
Diffstat (limited to 'src')
-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 |