aboutsummaryrefslogtreecommitdiff
path: root/src/archive.cc
diff options
context:
space:
mode:
authorAdrian Kummerlaender2017-10-07 16:57:15 +0200
committerAdrian Kummerlaender2017-10-07 16:57:15 +0200
commitc7a82e67007aecb46315780b53a691a519d90513 (patch)
treeccdeb8ae75a200ec41e34d79eba1ad9671f5a5da /src/archive.cc
parent51a422f161e7e7cc5b1093a12e004165754ec1b9 (diff)
downloadDictzipQuery-c7a82e67007aecb46315780b53a691a519d90513.tar
DictzipQuery-c7a82e67007aecb46315780b53a691a519d90513.tar.gz
DictzipQuery-c7a82e67007aecb46315780b53a691a519d90513.tar.bz2
DictzipQuery-c7a82e67007aecb46315780b53a691a519d90513.tar.lz
DictzipQuery-c7a82e67007aecb46315780b53a691a519d90513.tar.xz
DictzipQuery-c7a82e67007aecb46315780b53a691a519d90513.tar.zst
DictzipQuery-c7a82e67007aecb46315780b53a691a519d90513.zip
Introduce ArchiveFile class
Diffstat (limited to 'src/archive.cc')
-rw-r--r--src/archive.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/archive.cc b/src/archive.cc
new file mode 100644
index 0000000..6a97bdf
--- /dev/null
+++ b/src/archive.cc
@@ -0,0 +1,26 @@
+#include "archive.h"
+
+#include "istream/stream.h"
+
+namespace dictzip {
+
+ArchiveFile::ArchiveFile(const std::string& path):
+ path_(path) { }
+
+std::string ArchiveFile::get(std::size_t offset, std::size_t length) const {
+ Istream stream(this->path_.c_str());
+
+ std::string result;
+ result.resize(length);
+
+ stream.seekg(offset);
+ stream.read(&result[0], length);
+
+ return result;
+}
+
+std::string ArchiveFile::get(const IndexFile::Entry& entry) const {
+ return this->get(entry.offset, entry.length);
+}
+
+}