-
Notifications
You must be signed in to change notification settings - Fork 0
/
extractor.hpp
44 lines (32 loc) · 1005 Bytes
/
extractor.hpp
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
* extractor.hpp
*
* Created on: 20.01.2014
* Author: milo
*/
#ifndef EXTRACTOR_HPP_
#define EXTRACTOR_HPP_
#include <boost/filesystem.hpp>
#include <boost/utility.hpp>
#include <fstream>
#include "entity_header.hpp"
namespace SimpleTar {
class Extractor : boost::noncopyable {
public:
Extractor(const boost::filesystem::path& archive,
const boost::filesystem::path& output_dir);
void extract();
private:
void readHeader(EntityHeader& header);
void extractEntity(const EntityHeader& header);
void extractFile(const EntityHeader& header);
void extractDirectory(const EntityHeader& header);
size_t readBytes(char * buf, size_t bytes);
void copyFileFromArchive(const EntityHeader&header, const boost::filesystem::path& out_path);
void createDirs(const boost::filesystem::path& out_path);
bool archiveEnd();
boost::filesystem::path output_dir_;
std::ifstream archive_;
};
} //namespace SimpleTar
#endif /* EXTRACTOR_HPP_ */