summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-03-30 04:06:58 +0300
committerAndrei Karas <akaras@inbox.ru>2017-03-30 04:06:58 +0300
commit91d03c26c95a0982d4de41b039e1cdf8c55d90bc (patch)
tree9f8c533dbbe6c55d7ba71f7afa97816219e00e10
parentf8120f4c08f8b99d781c0a310ce1c0e383b256ae (diff)
downloadmv-91d03c26c95a0982d4de41b039e1cdf8c55d90bc.tar.gz
mv-91d03c26c95a0982d4de41b039e1cdf8c55d90bc.tar.bz2
mv-91d03c26c95a0982d4de41b039e1cdf8c55d90bc.tar.xz
mv-91d03c26c95a0982d4de41b039e1cdf8c55d90bc.zip
Improve VirtFsZip::rwops_seek.
-rw-r--r--src/fs/virtfs/virtfsziprwops.cpp28
1 files changed, 9 insertions, 19 deletions
diff --git a/src/fs/virtfs/virtfsziprwops.cpp b/src/fs/virtfs/virtfsziprwops.cpp
index 094d0c4b0..71e9ad397 100644
--- a/src/fs/virtfs/virtfsziprwops.cpp
+++ b/src/fs/virtfs/virtfsziprwops.cpp
@@ -39,6 +39,10 @@ namespace VirtFsZip
return -1;
VirtFile *const handle = static_cast<VirtFile *const>(
rw->hidden.unknown.data1);
+// const uint8_t *mBuf = handle->mBuf;
+ size_t mPos = handle->mPos;
+ size_t mSize = handle->mSize;
+
RWOPSINT pos = 0;
if (whence == SEEK_SET)
@@ -47,7 +51,7 @@ namespace VirtFsZip
}
else if (whence == SEEK_CUR)
{
- const int64_t current = VirtFs::tell(handle);
+ const int64_t current = mPos;
if (current == -1)
{
logger->assertLog(
@@ -70,23 +74,7 @@ namespace VirtFsZip
}
else if (whence == SEEK_END)
{
- const int64_t len = VirtFs::fileLength(handle);
- if (len == -1)
- {
- logger->assertLog(
- "VirtFs::rwops_seek:Can't find end of file.");
- return -1;
- }
-
- pos = static_cast<RWOPSINT>(len);
- if (static_cast<int64_t>(pos) != len)
- {
- logger->assertLog("VirtFs::rwops_seek: "
- "Can't fit end-of-file position in an int!");
- return -1;
- }
-
- pos += offset;
+ pos = mSize + offset;
}
else
{
@@ -102,7 +90,9 @@ namespace VirtFsZip
return -1;
}
- if (!VirtFs::seek(handle, static_cast<uint64_t>(pos)))
+ handle->mPos = pos;
+
+ if (pos > static_cast<RWOPSINT>(mSize))
{
logger->assertLog("VirtFs::rwops_seek: seek error.");
return -1;