summaryrefslogtreecommitdiff
path: root/src/fs/virtfsphys.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/virtfsphys.cpp
parent757069bdedabbd904e56d153e2e858db2a2cf2f1 (diff)
downloadmv-6388446b85e1fa5deccc6d5c1683fba88ef53d99.tar.gz
mv-6388446b85e1fa5deccc6d5c1683fba88ef53d99.tar.bz2
mv-6388446b85e1fa5deccc6d5c1683fba88ef53d99.tar.xz
mv-6388446b85e1fa5deccc6d5c1683fba88ef53d99.zip
Add functions pointers into VirtFile.
From VirtFs call if possible pointer from VirtFile.
Diffstat (limited to 'src/fs/virtfsphys.cpp')
-rw-r--r--src/fs/virtfsphys.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/fs/virtfsphys.cpp b/src/fs/virtfsphys.cpp
index 16b2c40df..d5cb1c1a2 100644
--- a/src/fs/virtfsphys.cpp
+++ b/src/fs/virtfsphys.cpp
@@ -22,6 +22,7 @@
#include "fs/virtfile.h"
#include "fs/virtfileprivate.h"
+#include "fs/virtfsfuncs.h"
#include "fs/virtlist.h"
#include "utils/checkutils.h"
@@ -38,6 +39,7 @@
namespace
{
const char *dirSeparator = nullptr;
+ VirtFsFuncs funcs;
} // namespace
namespace VirtFsPhys
@@ -63,6 +65,23 @@ namespace VirtFsPhys
}
updateDirSeparator();
atexit(reinterpret_cast<void(*)()>(PHYSFS_deinit));
+ initFuncs(&funcs);
+ }
+
+ void initFuncs()
+ {
+ initFuncs(&funcs);
+ }
+
+ void initFuncs(VirtFsFuncs *restrict const ptr)
+ {
+ ptr->close = &VirtFsPhys::close;
+ ptr->read = &VirtFsPhys::read;
+ ptr->write = &VirtFsPhys::write;
+ ptr->fileLength = &VirtFsPhys::fileLength;
+ ptr->tell = &VirtFsPhys::tell;
+ ptr->seek = &VirtFsPhys::seek;
+ ptr->eof = &VirtFsPhys::eof;
}
void updateDirSeparator()
@@ -126,7 +145,7 @@ namespace VirtFsPhys
filename.c_str());
if (!handle)
return nullptr;
- VirtFile *restrict const file = new VirtFile;
+ VirtFile *restrict const file = new VirtFile(&funcs);
file->mPrivate = new VirtFilePrivate(handle);
return file;
}
@@ -137,7 +156,7 @@ namespace VirtFsPhys
filename.c_str());
if (!handle)
return nullptr;
- VirtFile *restrict const file = new VirtFile;
+ VirtFile *restrict const file = new VirtFile(&funcs);
file->mPrivate = new VirtFilePrivate(handle);
return file;
}
@@ -148,7 +167,7 @@ namespace VirtFsPhys
filename.c_str());
if (!handle)
return nullptr;
- VirtFile *restrict const file = new VirtFile;
+ VirtFile *restrict const file = new VirtFile(&funcs);
file->mPrivate = new VirtFilePrivate(handle);
return file;
}