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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
#import "OFString.h"
#import "OFInvalidFormatException.h"
@implementation OFZooArchiveEntry
@synthesize compressionMethod = _compressionMethod, CRC16 = _CRC16;
@synthesize uncompressedSize = _uncompressedSize;
@synthesize compressedSize = _compressedSize, deleted = _deleted;
@synthesize fileComment = _fileComment, POSIXPermissions = _POSIXPermissions;
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)of_initWithStream: (OF_KINDOF(OFStream *))stream
encoding: (OFStringEncoding)encoding
{
self = [super init];
@try {
void *pool = objc_autoreleasePoolPush();
uint8_t majorVersion;
char fileNameBuffer[13];
uint32_t commentOffset;
uint16_t commentLength;
if ([stream readLittleEndianInt32] != 0xFDC4A7DC)
@throw [OFInvalidFormatException exception];
/* Type seems to be always 2 */
if ([stream readInt8] != 2)
@throw [OFInvalidFormatException exception];
_compressionMethod = [stream readInt8];
_nextHeaderOffset = [stream readLittleEndianInt32];
_dataOffset = [stream readLittleEndianInt32];
_lastModifiedFileDate = [stream readLittleEndianInt16];
_lastModifiedFileTime = [stream readLittleEndianInt16];
_CRC16 = [stream readLittleEndianInt16];
_uncompressedSize = [stream readLittleEndianInt32];
_compressedSize = [stream readLittleEndianInt32];
majorVersion = [stream readInt8];
/* Minor version */
[stream readInt8];
_deleted = [stream readInt8];
/* Unknown. Most likely padding to get to 2 byte alignment? */
[stream readInt8];
commentOffset = [stream readLittleEndianInt32];
commentLength = [stream readLittleEndianInt16];
[stream readIntoBuffer: fileNameBuffer exactLength: 13];
if (fileNameBuffer[12] != '\0')
fileNameBuffer[12] = '\0';
if (majorVersion == 2) {
uint16_t extraLength = [stream readLittleEndianInt16];
uint8_t fileNameLength, directoryNameLength;
if (extraLength < 10)
@throw [OFInvalidFormatException exception];
_timeZone = [stream readInt8];
|
|
>
<
|
<
<
|
|
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
#import "OFString.h"
#import "OFInvalidFormatException.h"
@implementation OFZooArchiveEntry
@synthesize compressionMethod = _compressionMethod, CRC16 = _CRC16;
@synthesize uncompressedSize = _uncompressedSize;
@synthesize compressedSize = _compressedSize;
@synthesize minVersionNeeded = _minVersionNeeded, deleted = _deleted;
@synthesize fileComment = _fileComment, POSIXPermissions = _POSIXPermissions;
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)of_initWithStream: (OF_KINDOF(OFStream *))stream
encoding: (OFStringEncoding)encoding
{
self = [super init];
@try {
void *pool = objc_autoreleasePoolPush();
char fileNameBuffer[13];
uint32_t commentOffset;
uint16_t commentLength;
if ([stream readLittleEndianInt32] != 0xFDC4A7DC)
@throw [OFInvalidFormatException exception];
/* Type seems to be always 2 */
if ([stream readInt8] != 2)
@throw [OFInvalidFormatException exception];
_compressionMethod = [stream readInt8];
_nextHeaderOffset = [stream readLittleEndianInt32];
_dataOffset = [stream readLittleEndianInt32];
_lastModifiedFileDate = [stream readLittleEndianInt16];
_lastModifiedFileTime = [stream readLittleEndianInt16];
_CRC16 = [stream readLittleEndianInt16];
_uncompressedSize = [stream readLittleEndianInt32];
_compressedSize = [stream readLittleEndianInt32];
_minVersionNeeded = [stream readBigEndianInt16];
_deleted = [stream readInt8];
/* Unknown. Most likely padding to get to 2 byte alignment? */
[stream readInt8];
commentOffset = [stream readLittleEndianInt32];
commentLength = [stream readLittleEndianInt16];
[stream readIntoBuffer: fileNameBuffer exactLength: 13];
if (fileNameBuffer[12] != '\0')
fileNameBuffer[12] = '\0';
if ((_minVersionNeeded >> 8) == 2) {
uint16_t extraLength = [stream readLittleEndianInt16];
uint8_t fileNameLength, directoryNameLength;
if (extraLength < 10)
@throw [OFInvalidFormatException exception];
_timeZone = [stream readInt8];
|