File: zip_dir.h

package info (click to toggle)
btanks 0.9.8083-9
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 43,616 kB
  • sloc: cpp: 46,425; ansic: 12,005; xml: 4,262; python: 313; sh: 13; makefile: 13
file content (51 lines) | stat: -rw-r--r-- 1,172 bytes parent folder | download | duplicates (5)
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
45
46
47
48
49
50
51
#ifndef MRT_ZIP_DIR_H__
#define MRT_ZIP_DIR_H__

#include "export_mrt.h"
#include "base_directory.h"
#include "file.h"
#include <map>
#include <set>
#include <string>
#include <vector>

namespace mrt {
class ZipFile;

class MRTAPI ZipDirectory : public mrt::BaseDirectory, public mrt::FSNode {

struct lessnocase {
	bool operator()(const std::string& s1, const std::string& s2) const;
};

public: 
	ZipDirectory(const std::string &zip);
	
	virtual void open(const std::string &path);
	virtual bool opened() const;
	virtual const std::string read() const;
	virtual void close();
	virtual void create(const std::string &path, const bool recurse = false);
	virtual ~ZipDirectory();
	ZipFile * open_file(const std::string &name) const;

	//FSNode: 
	virtual bool exists(const std::string &fname) const;

	void enumerate(std::vector<std::string>&files, const std::string &root) const;

private: 
	struct FileDesc {
		unsigned flags, method, offset, csize, usize;
		FileDesc() : flags(0), method(0), offset(0), csize(0), usize(0) {}
	};
	mrt::File archive;
	typedef std::map<const std::string, FileDesc, lessnocase> Headers;
	Headers headers;
	std::string fname;
};

}

#endif