ObjFW  Check-in [6985292473]

Overview
Comment:OFZooArchiveEntry: Handle time zone
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 69852924738484ef558a065ce04404b1584c42d4ca105f365a7101ae2cc8d520
User & Date: js on 2024-03-01 18:29:52
Other Links: manifest | tags
Context
2024-03-02
09:31
ofarc: Don't list/extract deleted files by default (check-in: 08eb6b5bca user: js tags: trunk)
2024-03-01
18:29
OFZooArchiveEntry: Handle time zone (check-in: 6985292473 user: js tags: trunk)
2024-02-28
23:08
OFZooArchiveEntry: Support for POSIX permissions (check-in: 38c16e3793 user: js tags: trunk)
Changes

Modified src/OFZooArchiveEntry.h from [15e60ca9a9] to [a47e00ad23].

38
39
40
41
42
43
44

45
46
47
48
49
50
51
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52







+







	uint16_t _lastModifiedFileDate, _lastModifiedFileTime;
	uint16_t _CRC16;
	unsigned long long _uncompressedSize, _compressedSize;
	bool _deleted;
	OFString *_Nullable _fileComment;
	OFString *_fileName, *_Nullable _directoryName;
	OFNumber *_Nullable _POSIXPermissions;
	uint8_t _timeZone;
	OF_RESERVE_IVARS(OFZooArchiveEntry, 4)
}

/**
 * @brief The compression method of the entry.
 */
@property (readonly, nonatomic) uint8_t compressionMethod;

Modified src/OFZooArchiveEntry.m from [c082c86574] to [8b961835b0].

79
80
81
82
83
84
85
86
87

88
89
90
91
92
93
94
79
80
81
82
83
84
85


86
87
88
89
90
91
92
93







-
-
+







		if (majorVersion == 2) {
			uint16_t extraLength = [stream readLittleEndianInt16];
			uint8_t fileNameLength, directoryNameLength;

			if (extraLength < 10)
				@throw [OFInvalidFormatException exception];

			/* Time zone */
			[stream readInt8];
			_timeZone = [stream readInt8];
			/* CRC16 of the header */
			[stream readLittleEndianInt16];

			fileNameLength = [stream readInt8];
			directoryNameLength = [stream readInt8];
			extraLength -= 2;

135
136
137
138
139
140
141
142

143
144
145


146
147
148
149
150
151
152
134
135
136
137
138
139
140

141
142
143
144
145
146
147
148
149
150
151
152
153







-
+



+
+








					_POSIXPermissions = [[OFNumber alloc]
					    initWithUnsignedShort: mode];
				}

				extraLength -= 3;
			}
		} else
		} else {
			_fileName = [[OFString alloc]
			    initWithCString: fileNameBuffer
				   encoding: encoding];
			_timeZone = 0x7F;
		}

		if (commentOffset != 0) {
			[stream seekToOffset: commentOffset whence: OFSeekSet];
			_fileComment = [[stream
			    readStringWithLength: commentLength
					encoding: encoding] retain];
		}
195
196
197
198
199
200
201

202


203






204
205
206
207
208
209
210
196
197
198
199
200
201
202
203

204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219







+
-
+
+

+
+
+
+
+
+







	OFDate *date;
	OFString *dateString;

	dateString = [OFString
	    stringWithFormat: @"%04u-%02u-%02u %02u:%02u:%02u",
			      year, month, day, hour, minute, second];

	if (_timeZone == 0x7F)
	date = [[OFDate alloc] initWithLocalDateString: dateString
		date = [[OFDate alloc]
		    initWithLocalDateString: dateString
						format: @"%Y-%m-%d %H:%M:%S"];
	else {
		date = [OFDate dateWithDateString: dateString
					   format: @"%Y-%m-%d %H:%M:%S"];
		date = [[date dateByAddingTimeInterval:
		    -(OFTimeInterval)_timeZone * 900] retain];
	}

	objc_autoreleasePoolPop(pool);

	return [date autorelease];
}

- (OFString *)description