summaryrefslogtreecommitdiff
path: root/src/fs/virtfszip.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-02-27 18:16:39 +0300
committerAndrei Karas <akaras@inbox.ru>2017-02-27 18:16:39 +0300
commit6388446b85e1fa5deccc6d5c1683fba88ef53d99 (patch)
treedaaa6c764a34aece74de45dddc5b1e276d61774d /src/fs/virtfszip.cpp
parent757069bdedabbd904e56d153e2e858db2a2cf2f1 (diff)
downloadplus-6388446b85e1fa5deccc6d5c1683fba88ef53d99.tar.gz
plus-6388446b85e1fa5deccc6d5c1683fba88ef53d99.tar.bz2
plus-6388446b85e1fa5deccc6d5c1683fba88ef53d99.tar.xz
plus-6388446b85e1fa5deccc6d5c1683fba88ef53d99.zip
Add functions pointers into VirtFile.
From VirtFs call if possible pointer from VirtFile.
Diffstat (limited to 'src/fs/virtfszip.cpp')
-rw-r--r--src/fs/virtfszip.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/fs/virtfszip.cpp b/src/fs/virtfszip.cpp
index fe75c0192..fa47892b5 100644
--- a/src/fs/virtfszip.cpp
+++ b/src/fs/virtfszip.cpp
@@ -24,6 +24,7 @@
#include "fs/paths.h"
#include "fs/virtfile.h"
#include "fs/virtfileprivate.h"
+#include "fs/virtfsfuncs.h"
#include "fs/virtlist.h"
#include "fs/virtzipentry.h"
#include "fs/zip.h"
@@ -40,6 +41,7 @@ extern const char *dirSeparator;
namespace
{
std::vector<VirtZipEntry*> mEntries;
+ VirtFsFuncs funcs;
} // namespace
namespace VirtFsZip
@@ -209,6 +211,22 @@ namespace VirtFsZip
mEntries.clear();
}
+ void init()
+ {
+ initFuncs(&funcs);
+ }
+
+ void initFuncs(VirtFsFuncs *restrict const ptr)
+ {
+ ptr->close = &VirtFsZip::close;
+ ptr->read = &VirtFsZip::read;
+ ptr->write = &VirtFsZip::write;
+ ptr->fileLength = &VirtFsZip::fileLength;
+ ptr->tell = &VirtFsZip::tell;
+ ptr->seek = &VirtFsZip::seek;
+ ptr->eof = &VirtFsZip::eof;
+ }
+
std::string getRealDir(const std::string &restrict filename)
{
if (checkPath(filename) == false)
@@ -337,7 +355,7 @@ namespace VirtFsZip
uint8_t *restrict const buf = Zip::readFile(header);
if (buf == nullptr)
return nullptr;
- VirtFile *restrict const file = new VirtFile;
+ VirtFile *restrict const file = new VirtFile(&funcs);
file->mPrivate = new VirtFilePrivate(buf,
header->uncompressSize);
return file;