aboutsummaryrefslogtreecommitdiff
path: root/src/archive.cc
blob: 6a97bdf063387d6bb346ee321685c3d5218ba1a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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);
}

}