︙ | | | ︙ | |
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#ifdef OF_HAVE_FILES
# import "OFFile.h"
#endif
#import "OFStream.h"
#import "OFSeekableStream.h"
#import "OFString.h"
#import "huffman_tree.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFNotImplementedException.h"
#import "OFNotOpenException.h"
#import "OFTruncatedDataException.h"
#define LHSTREAM_BUFFER_SIZE 4096
|
>
>
|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#ifdef OF_HAVE_FILES
# import "OFFile.h"
#endif
#import "OFStream.h"
#import "OFSeekableStream.h"
#import "OFString.h"
#import "crc16.h"
#import "huffman_tree.h"
#import "OFChecksumFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFNotImplementedException.h"
#import "OFNotOpenException.h"
#import "OFTruncatedDataException.h"
#define LHSTREAM_BUFFER_SIZE 4096
|
︙ | | | ︙ | |
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
dictionaryBits: (uint8_t)dictionaryBits;
@end
@interface OFLHAArchive_FileReadStream: OFStream <OFReadyForReadingObserving>
{
OF_KINDOF(OFStream *) _stream;
uint32_t _toRead;
bool _atEndOfStream;
}
- (instancetype)of_initWithStream: (OFStream *)stream
entry: (OFLHAArchiveEntry *)entry;
- (void)of_skip;
@end
|
>
|
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
dictionaryBits: (uint8_t)dictionaryBits;
@end
@interface OFLHAArchive_FileReadStream: OFStream <OFReadyForReadingObserving>
{
OF_KINDOF(OFStream *) _stream;
uint32_t _toRead;
uint16_t _expectedCRC16, _CRC16;
bool _atEndOfStream;
}
- (instancetype)of_initWithStream: (OFStream *)stream
entry: (OFLHAArchiveEntry *)entry;
- (void)of_skip;
@end
|
︙ | | | ︙ | |
724
725
726
727
728
729
730
731
732
733
734
735
736
737
|
if ([method isEqual: @"-lh0-"] || [method isEqual: @"-lhd-"] ||
[method isEqual: @"-lz4-"] || [method isEqual: @"-lh5-"] ||
[method isEqual: @"-lh6-"] || [method isEqual: @"-lh6-"])
_toRead = [entry uncompressedSize];
else
_toRead = [entry compressedSize];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
|
>
>
|
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
|
if ([method isEqual: @"-lh0-"] || [method isEqual: @"-lhd-"] ||
[method isEqual: @"-lz4-"] || [method isEqual: @"-lh5-"] ||
[method isEqual: @"-lh6-"] || [method isEqual: @"-lh6-"])
_toRead = [entry uncompressedSize];
else
_toRead = [entry compressedSize];
_expectedCRC16 = [entry CRC16];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
|
︙ | | | ︙ | |
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
|
if (length > _toRead)
length = _toRead;
ret = [_stream readIntoBuffer: buffer
length: length];
_toRead -= ret;
if (_toRead == 0)
_atEndOfStream = true;
return ret;
}
- (bool)lowlevelIsAtEndOfStream
{
if (_stream == nil)
|
>
|
>
>
>
>
|
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
|
if (length > _toRead)
length = _toRead;
ret = [_stream readIntoBuffer: buffer
length: length];
_toRead -= ret;
_CRC16 = of_crc16(_CRC16, buffer, ret);
if (_toRead == 0) {
_atEndOfStream = true;
if (_CRC16 != _expectedCRC16)
@throw [OFChecksumFailedException exception];
}
return ret;
}
- (bool)lowlevelIsAtEndOfStream
{
if (_stream == nil)
|
︙ | | | ︙ | |