fastdo
0.6.8
首页
命名空间
类
文件
文件列表
文件成员
compress.hpp
浏览该文件的文档.
1
#ifndef __COMPRESS_HPP__
2
#define __COMPRESS_HPP__
3
//
4
// compress 提供压缩功能
5
//
6
7
namespace
winux
8
{
9
10
typedef
winux::ulong
ZRESULT
;
11
// These are the zresult codes:
12
#define ZR_OK 0x00000000 // nb. the pseudo-code zr-recent is never returned,
13
#define ZR_RECENT 0x00000001 // but can be passed to FormatZipMessage.
14
// The following come from general system stuff (e.g. files not openable)
15
#define ZR_GENMASK 0x0000FF00
16
#define ZR_NODUPH 0x00000100 // couldn't duplicate the handle
17
#define ZR_NOFILE 0x00000200 // couldn't create/open the file
18
#define ZR_NOALLOC 0x00000300 // failed to allocate some resource
19
#define ZR_WRITE 0x00000400 // a general error writing to the file
20
#define ZR_NOTFOUND 0x00000500 // couldn't find that file in the zip
21
#define ZR_MORE 0x00000600 // there's still more data to be unzipped
22
#define ZR_CORRUPT 0x00000700 // the zipfile is corrupt or not a zipfile
23
#define ZR_READ 0x00000800 // a general error reading the file
24
#define ZR_PASSWORD 0x00001000 // we didn't get the right password to unzip the file
25
// The following come from mistakes on the part of the caller
26
#define ZR_CALLERMASK 0x00FF0000
27
#define ZR_ARGS 0x00010000 // general mistake with the arguments
28
#define ZR_NOTMMAP 0x00020000 // tried to ZipGetMemory, but that only works on mmap zipfiles, which yours wasn't
29
#define ZR_MEMSIZE 0x00030000 // the memory size is too small
30
#define ZR_FAILED 0x00040000 // the thing was already failed when you called this function
31
#define ZR_ENDED 0x00050000 // the zip creation has already been closed
32
#define ZR_MISSIZE 0x00060000 // the indicated input file size turned out mistaken
33
#define ZR_PARTIALUNZ 0x00070000 // the file had already been partially unzipped
34
#define ZR_ZMODE 0x00080000 // tried to mix creating/opening a zip
35
// The following come from bugs within the zip library itself
36
#define ZR_BUGMASK 0xFF000000
37
#define ZR_NOTINITED 0x01000000 // initialisation didn't work
38
#define ZR_SEEK 0x02000000 // trying to seek in an unseekable file
39
#define ZR_NOCHANGE 0x04000000 // changed its mind on storage, but not allowed
40
#define ZR_FLATE 0x05000000 // an internal error in the de/inflation code
41
43
class
WINUX_DLL
Zip
44
{
45
public
:
46
static
String
Message( ZRESULT code =
ZR_RECENT
);
47
48
Zip
();
49
Zip
(
String
const
& filename,
char
const
* password = NULL );
50
Zip
(
void
* buf,
uint32
size,
char
const
* password = NULL );
51
~
Zip
();
52
53
bool
create(
String
const
& filename,
char
const
* password = NULL );
54
bool
create(
void
* buf,
uint32
size,
char
const
* password = NULL );
55
ZRESULT close();
56
57
ZRESULT addFile(
String
const
& dstPathInZip,
String
const
& srcFilename );
58
ZRESULT addFile(
String
const
& dstPathInZip,
void
* src,
uint32
size );
59
ZRESULT addFolder(
String
const
& dstPathInZip );
60
61
void
zipAll(
String
const
& dirPath );
62
63
ZRESULT getMemory(
void
* * buf,
unsigned
long
* size );
64
65
private
:
66
MembersWrapper<struct Zip_Data>
_self;
67
68
DISABLE_OBJECT_COPY
(
Zip
)
69
};
70
72
class
WINUX_DLL
Unzip
73
{
74
public
:
75
typedef
struct
ZipEntry
76
{
77
int
index
;
// index of this file within the zip
78
String
name
;
// filename within the zip
79
winux::ulong
attr
;
// attributes, as in GetFileAttributes.
80
#if defined(__linux__) || ( defined(__GNUC__) && !defined(_WIN32) )
81
time_t atime,ctime,mtime;
// access, create, modify filetimes
82
#else
83
FILETIME atime,ctime,
mtime
;
// access, create, modify filetimes
84
#endif
85
long
comp_size
;
// sizes of item, compressed and uncompressed. These
86
long
unc_size
;
// may be -1 if not yet known (e.g. being streamed in)
87
}
ZipEntry
;
88
89
public
:
90
static
String
Message( ZRESULT code =
ZR_RECENT
);
91
92
Unzip
();
93
Unzip
(
String
const
& filename,
char
const
* password = NULL );
94
Unzip
(
void
* zipbuf,
uint32
size,
char
const
* password = NULL );
95
~
Unzip
();
96
97
bool
open(
String
const
& filename,
char
const
* password = NULL );
98
bool
open(
void
* zipbuf,
uint32
size,
char
const
* password = NULL );
99
ZRESULT close();
100
101
int
getEntriesCount()
const
;
102
103
ZRESULT getEntry(
int
index,
ZipEntry
* entry );
104
105
ZRESULT findEntry(
String
const
& name,
bool
caseInsensitive,
int
* index,
ZipEntry
* entry );
106
107
ZRESULT unzipEntry(
int
index,
String
const
& outFilename );
108
ZRESULT unzipEntry(
int
index,
void
* buf,
uint32
size );
109
void
unzipAll(
String
const
& dirPath =
""
);
110
111
ZRESULT setUnzipBaseDir(
String
const
& dirPath );
112
113
private
:
114
MembersWrapper<struct Unzip_Data>
_self;
115
116
DISABLE_OBJECT_COPY
(
Unzip
)
117
};
118
119
}
120
121
#endif // __COMPRESS_HPP__
winux::MembersWrapper< struct Zip_Data >
winux::Unzip::ZipEntry::comp_size
long comp_size
Definition:
compress.hpp:85
WINUX_DLL
#define WINUX_DLL
Definition:
utilities.hpp:60
winux::Unzip::ZipEntry::name
String name
Definition:
compress.hpp:78
winux::String
XString< tchar > String
Definition:
utilities.hpp:216
winux::Unzip::ZipEntry::attr
winux::ulong attr
Definition:
compress.hpp:79
ZR_RECENT
#define ZR_RECENT
Definition:
compress.hpp:13
DISABLE_OBJECT_COPY
#define DISABLE_OBJECT_COPY(clsname)
Definition:
utilities.hpp:81
winux::Unzip::ZipEntry::index
int index
Definition:
compress.hpp:77
winux::Unzip::ZipEntry::unc_size
long unc_size
Definition:
compress.hpp:86
winux::ZRESULT
winux::ulong ZRESULT
Definition:
compress.hpp:10
winux::Unzip::ZipEntry::mtime
FILETIME mtime
Definition:
compress.hpp:83
winux::Unzip::ZipEntry
Definition:
compress.hpp:75
winux::ulong
unsigned long ulong
Definition:
utilities.hpp:171
winux::uint32
unsigned int uint32
Definition:
utilities.hpp:170
winux::Zip
ZIP压缩
Definition:
compress.hpp:43
winux::Unzip
ZIP解压缩
Definition:
compress.hpp:72
winux
跨平台基础功能库
Definition:
archives.hpp:7
build
windows
include
compress.hpp
生成于 2023年 六月 18日 星期日 10:25:57 , 为 fastdo使用
1.8.11