ObjFW
Loading...
Searching...
No Matches
OFGZIPStream.h
1/*
2 * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
3 *
4 * All rights reserved.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License version 3.0 only,
8 * as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13 * version 3.0 for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * version 3.0 along with this program. If not, see
17 * <https://www.gnu.org/licenses/>.
18 */
19
20#import "OFStream.h"
21#import "OFDate.h"
22
23@class OFInflateStream;
24
25OF_ASSUME_NONNULL_BEGIN
26
30typedef enum {
31 OFGZIPStreamOperatingSystemFAT = 0,
32 OFGZIPStreamOperatingSystemAmiga = 1,
33 OFGZIPStreamOperatingSystemVMS = 2,
34 OFGZIPStreamOperatingSystemUNIX = 3,
35 OFGZIPStreamOperatingSystemVM_CMS = 4,
36 OFGZIPStreamOperatingSystemAtariTOS = 5,
37 OFGZIPStreamOperatingSystemHPFS = 6,
38 OFGZIPStreamOperatingSystemMacintosh = 7,
39 OFGZIPStreamOperatingSystemZSystem = 8,
40 OFGZIPStreamOperatingSystemCPM = 9,
41 OFGZIPStreamOperatingSystemTOPS20 = 10,
42 OFGZIPStreamOperatingSystemNTFS = 11,
43 OFGZIPStreamOperatingSystemQDO = 12,
44 OFGZIPStreamOperatingSystemAcornRISCOS = 13,
45 OFGZIPStreamOperatingSystemUnknown = 255
46} OFGZIPStreamOperatingSystem;
47
54OF_SUBCLASSING_RESTRICTED
56{
57 OFStream *_stream;
58 OFInflateStream *_Nullable _inflateStream;
59 enum {
60 OFGZIPStreamStateID1,
61 OFGZIPStreamStateID2,
62 OFGZIPStreamStateCompressionMethod,
63 OFGZIPStreamStateFlags,
64 OFGZIPStreamStateModificationDate,
65 OFGZIPStreamStateExtraFlags,
66 OFGZIPStreamStateOperatingSystem,
67 OFGZIPStreamStateExtraLength,
68 OFGZIPStreamStateExtra,
69 OFGZIPStreamStateName,
70 OFGZIPStreamStateComment,
71 OFGZIPStreamStateHeaderCRC16,
72 OFGZIPStreamStateData,
73 OFGZIPStreamStateCRC32,
74 OFGZIPStreamStateUncompressedSize
75 } _state;
76 enum {
77 OFGZIPStreamFlagText = 0x01,
78 OFGZIPStreamFlagHeaderCRC16 = 0x02,
79 OFGZIPStreamFlagExtra = 0x04,
80 OFGZIPStreamFlagName = 0x08,
81 OFGZIPStreamFlagComment = 0x10
82 } _flags;
83 uint8_t _extraFlags;
84 OFGZIPStreamOperatingSystem _operatingSystemMadeOn;
85 size_t _bytesRead;
86 uint8_t _buffer[4];
87 OFDate *_Nullable _modificationDate;
88 uint16_t _extraLength;
89 uint32_t _CRC32, _uncompressedSize;
90}
91
98@property (readonly, nonatomic)
99 OFGZIPStreamOperatingSystem operatingSystemMadeOn;
100
107@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFDate *modificationDate;
108
117+ (instancetype)streamWithStream: (OFStream *)stream mode: (OFString *)mode;
118
119- (instancetype)init OF_UNAVAILABLE;
120
130- (instancetype)initWithStream: (OFStream *)stream
131 mode: (OFString *)mode OF_DESIGNATED_INITIALIZER;
132@end
133
134OF_ASSUME_NONNULL_END
A class for storing, accessing and comparing dates.
Definition OFDate.h:34
A class that handles GZIP compression and decompression transparently for an underlying stream.
Definition OFGZIPStream.h:56
OFDate * modificationDate
The modification date of the original file.
Definition OFGZIPStream.h:107
A class that handles Deflate decompression transparently for an underlying stream.
Definition OFInflateStream.h:39
A base class for different types of streams.
Definition OFStream.h:192
A class for handling strings.
Definition OFString.h:139