ObjFW  Diff

Differences From Artifact [2572905d24]:

  • File utils/ofzip/GZIPArchive.m — part of check-in [34e0dcaf87] at 2016-04-24 02:32:33 on branch trunk — OFZIP: Add GZIP support (user: js size: 2227)

To Artifact [7bb45e0fc2]:

  • File utils/ofzip/GZIPArchive.m — part of check-in [f984c522b1] at 2016-04-24 14:36:23 on branch trunk — OFZIP: Preserve mode when extracting .gz files (user: js size: 2590)

13
14
15
16
17
18
19

20
21
22
23
24
25













26
27
28
29
30
31
32
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46







+






+
+
+
+
+
+
+
+
+
+
+
+
+







 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#import "OFApplication.h"
#import "OFFileManager.h"
#import "OFStdIOStream.h"

#import "GZIPArchive.h"
#import "OFZIP.h"

static OFZIP *app;

static void
setPermissions(OFString *destination, OFString *source)
{
#ifdef OF_HAVE_CHMOD
	OFFileManager *fileManager = [OFFileManager defaultManager];
	mode_t mode;

	mode = [fileManager permissionsOfItemAtPath: source];
	[fileManager changePermissionsOfItemAtPath: destination
				       permissions: mode];
#endif
}

@implementation GZIPArchive
+ (void)initialize
{
	if (self == [GZIPArchive class])
		app = [[OFApplication sharedApplication] delegate];
}
83
84
85
86
87
88
89
90

91
92
93
94
95
96
97
97
98
99
100
101
102
103

104
105
106
107
108
109
110
111







-
+








	if (![app shouldExtractFile: fileName
			outFileName: fileName])
		return;

	output = [OFFile fileWithPath: fileName
				 mode: @"wb"];
	/* TODO: Copy permissions */
	setPermissions(fileName, app->_archivePath);

	while (![_stream isAtEndOfStream]) {
		ssize_t length = [app copyBlockFromStream: _stream
						 toStream: output
						 fileName: fileName];

		if (length < 0) {