ObjFW  Check-in [f984c522b1]

Overview
Comment:OFZIP: Preserve mode when extracting .gz files
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f984c522b1f60390e9cc43ae6fb5ad84413a2b405837540ca0ef63ac007cc96d
User & Date: js on 2016-04-24 14:36:23
Other Links: manifest | tags
Context
2016-04-24
15:31
Move of_tlskey_{new,free} to API-specific files check-in: 4b31620e27 user: js tags: trunk
14:36
OFZIP: Preserve mode when extracting .gz files check-in: f984c522b1 user: js tags: trunk
14:28
OFFileManager: Documentation improvements check-in: a0ffd80bef user: js tags: trunk
Changes

Modified utils/ofzip/GZIPArchive.m from [2572905d24] to [7bb45e0fc2].

13
14
15
16
17
18
19

20
21
22
23
24
25













26
27
28
29
30
31
32
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#import "OFApplication.h"

#import "OFStdIOStream.h"

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

static OFZIP *app;














@implementation GZIPArchive
+ (void)initialize
{
	if (self == [GZIPArchive class])
		app = [[OFApplication sharedApplication] delegate];
}







>






>
>
>
>
>
>
>
>
>
>
>
>
>







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

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

	output = [OFFile fileWithPath: fileName
				 mode: @"wb"];
	/* TODO: Copy permissions */

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

		if (length < 0) {







|







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"];
	setPermissions(fileName, app->_archivePath);

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

		if (length < 0) {