ObjFW  Check-in [41949ecc65]

Overview
Comment:ofzip: Support for writing files

Not supported for any file formats, yet.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 41949ecc658dcd3fdac086ef2b5a0cafc451734736123d24cbb5ff25160de744
User & Date: js on 2017-08-05 17:48:55
Other Links: manifest | tags
Context
2017-08-05
18:00
OFZIPArchive: Don't require an OFSeekableStream check-in: c404c33cf1 user: js tags: trunk
17:48
ofzip: Support for writing files check-in: 41949ecc65 user: js tags: trunk
17:24
OFGZIPStream: Prepare for adding write support check-in: ccf8ecbb83 user: js tags: trunk
Changes

Modified utils/ofzip/Archive.h from [9f8454bed8] to [c9b737aa7a].

15
16
17
18
19
20
21
22

23

24
25
26


27
 */

#import "OFObject.h"
#import "OFFile.h"
#import "OFArray.h"

@protocol Archive <OFObject>
+ (instancetype)archiveWithStream: (OF_KINDOF(OFStream *))stream;

- initWithStream: (OF_KINDOF(OFStream *))stream;

- (void)listFiles;
- (void)extractFiles: (OFArray OF_GENERIC(OFString *) *)files;
- (void)printFiles: (OFArray OF_GENERIC(OFString* ) *)files;


@end







|
>
|
>


|
>
>

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 */

#import "OFObject.h"
#import "OFFile.h"
#import "OFArray.h"

@protocol Archive <OFObject>
+ (instancetype)archiveWithStream: (OF_KINDOF(OFStream *))stream
			     mode: (OFString *)mode;
- initWithStream: (OF_KINDOF(OFStream *))stream
	    mode: (OFString *)mode;
- (void)listFiles;
- (void)extractFiles: (OFArray OF_GENERIC(OFString *) *)files;
- (void)printFiles: (OFArray OF_GENERIC(OFString *) *)files;
@optional
- (void)addFiles: (OFArray OF_GENERIC(OFString *) *)files;
@end

Modified utils/ofzip/GZIPArchive.m from [85573597fb] to [39d718e85f].

42
43
44
45
46
47
48

49
50

51
52
53

54
55
56
57
58
59
60
61
62
63
64
65
66
+ (void)initialize
{
	if (self == [GZIPArchive class])
		app = (OFZIP *)[[OFApplication sharedApplication] delegate];
}

+ (instancetype)archiveWithStream: (OF_KINDOF(OFStream *))stream

{
	return [[[self alloc] initWithStream: stream] autorelease];

}

- initWithStream: (OF_KINDOF(OFStream *))stream

{
	self = [super init];

	@try {
		_stream = [[OFGZIPStream alloc] initWithStream: stream
							  mode: @"r"];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}







>

|
>



>





|







42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
+ (void)initialize
{
	if (self == [GZIPArchive class])
		app = (OFZIP *)[[OFApplication sharedApplication] delegate];
}

+ (instancetype)archiveWithStream: (OF_KINDOF(OFStream *))stream
			     mode: (OFString *)mode
{
	return [[[self alloc] initWithStream: stream
					mode: mode] autorelease];
}

- initWithStream: (OF_KINDOF(OFStream *))stream
	    mode: (OFString *)mode
{
	self = [super init];

	@try {
		_stream = [[OFGZIPStream alloc] initWithStream: stream
							  mode: mode];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

Modified utils/ofzip/OFZIP.h from [b2525a3db1] to [afc71f5901].

32
33
34
35
36
37
38
39

40
41
42
43
44
45
@public
	int8_t _outputLevel;
	OFString *_archivePath;
	int _exitStatus;
}

- (id <Archive>)openArchiveWithPath: (OFString *)path
			       type: (OFString *)type;

- (bool)shouldExtractFile: (OFString *)fileName
	      outFileName: (OFString *)outFileName;
- (ssize_t)copyBlockFromStream: (OFStream *)input
		      toStream: (OFStream *)output
		      fileName: (OFString *)fileName;
@end







|
>






32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
@public
	int8_t _outputLevel;
	OFString *_archivePath;
	int _exitStatus;
}

- (id <Archive>)openArchiveWithPath: (OFString *)path
			       type: (OFString *)type
			       mode: (char)mode;
- (bool)shouldExtractFile: (OFString *)fileName
	      outFileName: (OFString *)outFileName;
- (ssize_t)copyBlockFromStream: (OFStream *)input
		      toStream: (OFStream *)output
		      fileName: (OFString *)fileName;
@end

Modified utils/ofzip/OFZIP.m from [772087febb] to [8ac0b34839].

29
30
31
32
33
34
35

36

37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56


57
58
59
60
61
62
63

#import "OFZIP.h"
#import "GZIPArchive.h"
#import "TarArchive.h"
#import "ZIPArchive.h"

#import "OFCreateDirectoryFailedException.h"

#import "OFInvalidFormatException.h"

#import "OFOpenItemFailedException.h"
#import "OFReadFailedException.h"
#import "OFSeekFailedException.h"
#import "OFWriteFailedException.h"

#define BUFFER_SIZE 4096

OF_APPLICATION_DELEGATE(OFZIP)

static void
help(OFStream *stream, bool full, int status)
{
	[stream writeLine: OF_LOCALIZED(@"usage",
	    @"Usage: %[prog] -[Cfhlnpqtvx] archive.zip [file1 file2 ...]",
	    @"prog", [OFApplication programName])];

	if (full) {
		[stream writeString: @"\n"];
		[stream writeLine: OF_LOCALIZED(@"full_usage",
		    @"Options:\n"


		    @"    -C  --directory   Extract into the specified "
		    @"directory\n"
		    @"    -f  --force       Force / overwrite files\n"
		    @"    -h  --help        Show this help\n"
		    @"    -l  --list        List all files in the archive\n"
		    @"    -n  --no-clobber  Never overwrite files\n"
		    @"    -p  --print       Print one or more files from the "







>

>













|






>
>







29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67

#import "OFZIP.h"
#import "GZIPArchive.h"
#import "TarArchive.h"
#import "ZIPArchive.h"

#import "OFCreateDirectoryFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFNotImplementedException.h"
#import "OFOpenItemFailedException.h"
#import "OFReadFailedException.h"
#import "OFSeekFailedException.h"
#import "OFWriteFailedException.h"

#define BUFFER_SIZE 4096

OF_APPLICATION_DELEGATE(OFZIP)

static void
help(OFStream *stream, bool full, int status)
{
	[stream writeLine: OF_LOCALIZED(@"usage",
	    @"Usage: %[prog] -[acCfhlnpqtvx] archive.zip [file1 file2 ...]",
	    @"prog", [OFApplication programName])];

	if (full) {
		[stream writeString: @"\n"];
		[stream writeLine: OF_LOCALIZED(@"full_usage",
		    @"Options:\n"
		    @"    -a  --append      Append to archive\n"
		    @"    -c  --create      Create archive\n"
		    @"    -C  --directory   Extract into the specified "
		    @"directory\n"
		    @"    -f  --force       Force / overwrite files\n"
		    @"    -h  --help        Show this help\n"
		    @"    -l  --list        List all files in the archive\n"
		    @"    -n  --no-clobber  Never overwrite files\n"
		    @"    -p  --print       Print one or more files from the "
89
90
91
92
93
94
95
96
97
98


99
100
101
102
103
104
105




106
107
108
109

110
111
112
113
114
115
116














117
118
119
120
121
122
123
124


125
126
127
128
129
130
131
	    @"longopt1", longOption1,
	    @"shortopt2", shortOption2Str,
	    @"longopt2", longOption2)];
	[OFApplication terminateWithStatus: 1];
}

static void
mutuallyExclusiveError3(of_unichar_t shortOption1, OFString *longOption1,
    of_unichar_t shortOption2, OFString *longOption2,
    of_unichar_t shortOption3, OFString *longOption3)


{
	OFString *shortOption1Str = [OFString stringWithFormat: @"%C",
								shortOption1];
	OFString *shortOption2Str = [OFString stringWithFormat: @"%C",
								shortOption2];
	OFString *shortOption3Str = [OFString stringWithFormat: @"%C",
								shortOption3];





	[of_stderr writeLine: OF_LOCALIZED(@"3_options_mutually_exclusive",
	    @"Error: -%[shortopt1] / --%[longopt1], "
	    @"-%[shortopt2] / --%[longopt2] and -%[shortopt3] / --%[longopt3] "

	    @"are mutually exclusive!",
	    @"shortopt1", shortOption1Str,
	    @"longopt1", longOption1,
	    @"shortopt2", shortOption2Str,
	    @"longopt2", longOption2,
	    @"shortopt3", shortOption3Str,
	    @"longopt3", longOption3)];














	[OFApplication terminateWithStatus: 1];
}

@implementation OFZIP
- (void)applicationDidFinishLaunching
{
	OFString *outputDir = nil, *type = nil;
	const of_options_parser_option_t options[] = {


		{ 'C', @"directory", 1, NULL, &outputDir },
		{ 'f', @"force", 0, NULL, NULL },
		{ 'h', @"help", 0, NULL, NULL },
		{ 'l', @"list", 0, NULL, NULL },
		{ 'n', @"no-clobber", 0, NULL, NULL },
		{ 'p', @"print", 0, NULL, NULL },
		{ 'q', @"quiet", 0, NULL, NULL },







|

|
>
>







>
>
>
>

|

|
>
|





|
>
>
>
>
>
>
>
>
>
>
>
>
>
>








>
>







93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
	    @"longopt1", longOption1,
	    @"shortopt2", shortOption2Str,
	    @"longopt2", longOption2)];
	[OFApplication terminateWithStatus: 1];
}

static void
mutuallyExclusiveError5(of_unichar_t shortOption1, OFString *longOption1,
    of_unichar_t shortOption2, OFString *longOption2,
    of_unichar_t shortOption3, OFString *longOption3,
    of_unichar_t shortOption4, OFString *longOption4,
    of_unichar_t shortOption5, OFString *longOption5)
{
	OFString *shortOption1Str = [OFString stringWithFormat: @"%C",
								shortOption1];
	OFString *shortOption2Str = [OFString stringWithFormat: @"%C",
								shortOption2];
	OFString *shortOption3Str = [OFString stringWithFormat: @"%C",
								shortOption3];
	OFString *shortOption4Str = [OFString stringWithFormat: @"%C",
								shortOption4];
	OFString *shortOption5Str = [OFString stringWithFormat: @"%C",
								shortOption5];

	[of_stderr writeLine: OF_LOCALIZED(@"5_options_mutually_exclusive",
	    @"Error: -%[shortopt1] / --%[longopt1], "
	    @"-%[shortopt2] / --%[longopt2], -%[shortopt3] / --%[longopt3], "
	    @"-%[shortopt4] / --%[longopt4] and\n"
	    @"       -%[shortopt5] / --%[longopt5] are mutually exclusive!",
	    @"shortopt1", shortOption1Str,
	    @"longopt1", longOption1,
	    @"shortopt2", shortOption2Str,
	    @"longopt2", longOption2,
	    @"shortopt3", shortOption3Str,
	    @"longopt3", longOption3,
	    @"shortopt4", shortOption4Str,
	    @"longopt4", longOption4,
	    @"shortopt5", shortOption5Str,
	    @"longopt5", longOption5)];
	[OFApplication terminateWithStatus: 1];
}

static void
writingNotSupported(OFString *type)
{
	[of_stderr writeLine: OF_LOCALIZED(
	    @"writing_not_supported",
	    @"Writing archives of type %[type] is not (yet) supported!",
	    @"type", type)];
	[OFApplication terminateWithStatus: 1];
}

@implementation OFZIP
- (void)applicationDidFinishLaunching
{
	OFString *outputDir = nil, *type = nil;
	const of_options_parser_option_t options[] = {
		{ 'a', @"append", 0, NULL, NULL },
		{ 'c', @"create", 0, NULL, NULL },
		{ 'C', @"directory", 1, NULL, &outputDir },
		{ 'f', @"force", 0, NULL, NULL },
		{ 'h', @"help", 0, NULL, NULL },
		{ 'l', @"list", 0, NULL, NULL },
		{ 'n', @"no-clobber", 0, NULL, NULL },
		{ 'p', @"print", 0, NULL, NULL },
		{ 'q', @"quiet", 0, NULL, NULL },
187
188
189
190
191
192
193
194
195

196

197
198


199
200

201
202
203
204
205
206
207
		case 'q':
			if (_outputLevel > 0)
				mutuallyExclusiveError(
				    'q', @"quiet", 'v', @"verbose");

			_outputLevel--;
			break;
		case 'l':
		case 'x':

		case 'p':

			if (mode != '\0')
				mutuallyExclusiveError3(


				    'l', @"list", 'x', @"extract",
				    'p', @"print");


			mode = option;
			break;
		case 'h':
			help(of_stdout, true, 0);
			break;
		case '=':







|
|
>

>

|
>
>
|
|
>







214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
		case 'q':
			if (_outputLevel > 0)
				mutuallyExclusiveError(
				    'q', @"quiet", 'v', @"verbose");

			_outputLevel--;
			break;
		case 'a':
		case 'c':
		case 'l':
		case 'p':
		case 'x':
			if (mode != '\0')
				mutuallyExclusiveError5(
				    'a', @"append",
				    'c', @"create",
				    'l', @"list",
				    'p', @"print",
				    'x', @"extract");

			mode = option;
			break;
		case 'h':
			help(of_stdout, true, 0);
			break;
		case '=':
233
234
235
236
237
238
239
240

241
242
243
244
245
246
247

			[OFApplication terminateWithStatus: 1];
		}
	}

	remainingArguments = [optionsParser remainingArguments];
	archive = [self openArchiveWithPath: [remainingArguments firstObject]
				       type: type];


	if (outputDir != nil)
		[[OFFileManager defaultManager]
		    changeCurrentDirectoryPath: outputDir];

	switch (mode) {
	case 'l':







|
>







265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280

			[OFApplication terminateWithStatus: 1];
		}
	}

	remainingArguments = [optionsParser remainingArguments];
	archive = [self openArchiveWithPath: [remainingArguments firstObject]
				       type: type
				       mode: mode];

	if (outputDir != nil)
		[[OFFileManager defaultManager]
		    changeCurrentDirectoryPath: outputDir];

	switch (mode) {
	case 'l':
299
300
301
302
303
304
305

306

307
308
309
310
311
312
313
314

















315
316
317
318
319
320
321
322
323
324
325
	}

	[OFApplication terminateWithStatus: _exitStatus];
}

- (id <Archive>)openArchiveWithPath: (OFString *)path
			       type: (OFString *)type

{

	OFFile *file = nil;
	id <Archive> archive = nil;

	[_archivePath release];
	_archivePath = [path copy];

	if (path == nil)
		return nil;


















	@try {
		file = [OFFile fileWithPath: path
				       mode: @"r"];
	} @catch (OFOpenItemFailedException *e) {
		OFString *error = [OFString
		    stringWithCString: strerror([e errNo])
			     encoding: [OFLocalization encoding]];
		[of_stderr writeString: @"\r"];
		[of_stderr writeLine: OF_LOCALIZED(
		    @"failed_to_open_file",







>

>








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



|







332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
	}

	[OFApplication terminateWithStatus: _exitStatus];
}

- (id <Archive>)openArchiveWithPath: (OFString *)path
			       type: (OFString *)type
			       mode: (char)mode
{
	OFString *modeString, *fileModeString;
	OFFile *file = nil;
	id <Archive> archive = nil;

	[_archivePath release];
	_archivePath = [path copy];

	if (path == nil)
		return nil;

	switch (mode) {
	case 'a':
		modeString = @"a";
		fileModeString = @"r+";
		break;
	case 'c':
		modeString = fileModeString = @"w";
		break;
	case 'l':
	case 'p':
	case 'x':
		modeString = fileModeString = @"r";
		break;
	default:
		@throw [OFInvalidArgumentException exception];
	}

	@try {
		file = [OFFile fileWithPath: path
				       mode: fileModeString];
	} @catch (OFOpenItemFailedException *e) {
		OFString *error = [OFString
		    stringWithCString: strerror([e errNo])
			     encoding: [OFLocalization encoding]];
		[of_stderr writeString: @"\r"];
		[of_stderr writeLine: OF_LOCALIZED(
		    @"failed_to_open_file",
340
341
342
343
344
345
346
347

348
349

350



351
352
353
354
355

356
357
358
359
360
361
362






363
364
365
366
367
368
369
			type = @"tar";
		else
			type = @"zip";
	}

	@try {
		if ([type isEqual: @"gz"])
			archive = [GZIPArchive archiveWithStream: file];

		else if ([type isEqual: @"tar"])
			archive = [TarArchive archiveWithStream: file];

		else if ([type isEqual: @"tgz"])



			archive = [TarArchive archiveWithStream:
			    [OFGZIPStream streamWithStream: file
						      mode: @"r"]];
		else if ([type isEqual: @"zip"])
			archive = [ZIPArchive archiveWithStream: file];

		else {
			[of_stderr writeLine: OF_LOCALIZED(
			    @"unknown_archive_type",
			    @"Unknown archive type: %[type]",
			    @"type", type)];
			[OFApplication terminateWithStatus: 1];
		}






	} @catch (OFReadFailedException *e) {
		OFString *error = [OFString
		    stringWithCString: strerror([e errNo])
			     encoding: [OFLocalization encoding]];
		[of_stderr writeLine: OF_LOCALIZED(@"failed_to_read_file",
		    @"Failed to read file %[file]: %[error]",
		    @"file", path,







|
>

|
>
|
>
>
>
|
<
|
|
|
>







>
>
>
>
>
>







392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408

409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
			type = @"tar";
		else
			type = @"zip";
	}

	@try {
		if ([type isEqual: @"gz"])
			archive = [GZIPArchive archiveWithStream: file
							    mode: modeString];
		else if ([type isEqual: @"tar"])
			archive = [TarArchive archiveWithStream: file
							   mode: modeString];
		else if ([type isEqual: @"tgz"]) {
			OFStream *GZIPStream = [OFGZIPStream
			    streamWithStream: file
					mode: modeString];
			archive = [TarArchive archiveWithStream: GZIPStream

							   mode: modeString];
		} else if ([type isEqual: @"zip"])
			archive = [ZIPArchive archiveWithStream: file
							   mode: modeString];
		else {
			[of_stderr writeLine: OF_LOCALIZED(
			    @"unknown_archive_type",
			    @"Unknown archive type: %[type]",
			    @"type", type)];
			[OFApplication terminateWithStatus: 1];
		}
	} @catch (OFNotImplementedException *e) {
		if ((mode == 'a' || mode == 'c') &&
		    sel_isEqual([e selector], @selector(initWithStream:mode:)))
			writingNotSupported(type);

		@throw e;
	} @catch (OFReadFailedException *e) {
		OFString *error = [OFString
		    stringWithCString: strerror([e errNo])
			     encoding: [OFLocalization encoding]];
		[of_stderr writeLine: OF_LOCALIZED(@"failed_to_read_file",
		    @"Failed to read file %[file]: %[error]",
		    @"file", path,
381
382
383
384
385
386
387




388
389
390
391
392
393
394
	} @catch (OFInvalidFormatException *e) {
		[of_stderr writeLine: OF_LOCALIZED(
		    @"file_is_not_a_valid_archive",
		    @"File %[file] is not a valid archive!",
		    @"file", path)];
		[OFApplication terminateWithStatus: 1];
	}





	return archive;
}

- (bool)shouldExtractFile: (OFString *)fileName
	      outFileName: (OFString *)outFileName
{







>
>
>
>







444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
	} @catch (OFInvalidFormatException *e) {
		[of_stderr writeLine: OF_LOCALIZED(
		    @"file_is_not_a_valid_archive",
		    @"File %[file] is not a valid archive!",
		    @"file", path)];
		[OFApplication terminateWithStatus: 1];
	}

	if ((mode == 'a' || mode == 'c') &&
	    ![archive respondsToSelector: @selector(addFiles:)])
		writingNotSupported(type);

	return archive;
}

- (bool)shouldExtractFile: (OFString *)fileName
	      outFileName: (OFString *)outFileName
{

Modified utils/ofzip/TarArchive.m from [49a8dc5d2b] to [50de2565fd].

44
45
46
47
48
49
50

51
52

53
54
55

56
57
58
59
60
61
62
63
64
65
66
67
68
+ (void)initialize
{
	if (self == [TarArchive class])
		app = (OFZIP *)[[OFApplication sharedApplication] delegate];
}

+ (instancetype)archiveWithStream: (OF_KINDOF(OFStream *))stream

{
	return [[[self alloc] initWithStream: stream] autorelease];

}

- initWithStream: (OF_KINDOF(OFStream *))stream

{
	self = [super init];

	@try {
		_archive = [[OFTarArchive alloc] initWithStream: stream
							   mode: @"r"];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}







>

|
>



>





|







44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
+ (void)initialize
{
	if (self == [TarArchive class])
		app = (OFZIP *)[[OFApplication sharedApplication] delegate];
}

+ (instancetype)archiveWithStream: (OF_KINDOF(OFStream *))stream
			     mode: (OFString *)mode
{
	return [[[self alloc] initWithStream: stream
					mode: mode] autorelease];
}

- initWithStream: (OF_KINDOF(OFStream *))stream
	    mode: (OFString *)mode
{
	self = [super init];

	@try {
		_archive = [[OFTarArchive alloc] initWithStream: stream
							   mode: mode];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

Modified utils/ofzip/ZIPArchive.m from [01768df2ad] to [4d9fbe54f7].

53
54
55
56
57
58
59

60
61

62
63
64

65
66
67
68
69
70
71
72
73
74
75
76
77
78
+ (void)initialize
{
	if (self == [ZIPArchive class])
		app = (OFZIP *)[[OFApplication sharedApplication] delegate];
}

+ (instancetype)archiveWithStream: (OF_KINDOF(OFStream *))stream

{
	return [[[self alloc] initWithStream: stream] autorelease];

}

- initWithStream: (OF_KINDOF(OFStream *))stream

{
	self = [super init];

	@try {
		_archive = [[OFZIPArchive alloc]
		    initWithSeekableStream: stream
				      mode: @"r"];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}







>

|
>



>




|
<
|







53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72

73
74
75
76
77
78
79
80
+ (void)initialize
{
	if (self == [ZIPArchive class])
		app = (OFZIP *)[[OFApplication sharedApplication] delegate];
}

+ (instancetype)archiveWithStream: (OF_KINDOF(OFStream *))stream
			     mode: (OFString *)mode
{
	return [[[self alloc] initWithStream: stream
					mode: mode] autorelease];
}

- initWithStream: (OF_KINDOF(OFStream *))stream
	    mode: (OFString *)mode
{
	self = [super init];

	@try {
		_archive = [[OFZIPArchive alloc] initWithSeekableStream: stream

								   mode: mode];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

Modified utils/ofzip/lang/de.json from [eaae508b7c] to [e0aac008e1].

1
2
3
4
5
6


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25


26
27
28
29



30
31
32
33
34
35
36
{
    "usage": [
        "Benutzung: %[prog] -[Cfhlnpqtvx] archiv.zip [datei1 datei2 ...]"
    ],
    "full_usage": [
        "Optionen:\n",


        "    -C  --directory   In angegebenes Verzeichnis entpacken\n",
        "    -f  --force       Existierende Dateien überschreiben\n",
        "    -h  --help        Diese Hilfe anzeigen\n",
        "    -l  --list        Alle Dateien im Archiv auflisten\n",
        "    -n  --no-clobber  Dateien niemals überschreiben\n",
        "    -p  --print       Eine oder mehr Dateien aus dem Archiv ausgeben",
	"\n",
        "    -q  --quiet       Ruhiger Modus (keine Ausgabe außer Fehler)\n",
        "    -t  --type        Archiv-Typ (gz, tar, tgz, zip)\n",
        "    -v  --verbose     Ausführlicher Modus für Datei-Liste\n",
        "    -x  --extract     Dateien entpacken"
    ],
    "2_options_mutually_exclusive": [
        "Fehler: -%[shortopt1] / --%[longopt1] und ",
        "-%[shortopt2] / --%[longopt2] schließen sich gegenseitig aus!"
    ],
    "3_options_mutually_exclusive": [
        "Fehler: -%[shortopt1] / --%[longopt1], -%[shortopt2] / --%[longopt2] ",
        "und -%[shortopt3] / --%[longopt3] schließen sich gegenseitig aus!"


    ],
    "option_takes_no_argument": "%[prog]: Option --%[opt] nimmt kein Argument",
    "unknown_long_option": "%[prog]: Unbekannte Option: --%[opt]",
    "unknown_option": "%[prog]: Unbekannte Option: -%[opt]",



    "failed_to_create_directory": [
        "Fehler beim Erstellen des Verzeichnis %[dir]: %[error]"
    ],
    "failed_to_open_file": "Fehler beim Öffnen der Datei %[file]: %[error]",
    "unknown_archive_type": "Unbekannter Archivtyp: %[type]",
    "failed_to_read_file": "Fehler beim Lesen der Datei %[file]: %[error]",
    "failed_to_write_file": "Fehler beim Schreiben der Datei %[file]: %[error]",


|



>
>






|









|
|
|
>
>




>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
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
{
    "usage": [
        "Benutzung: %[prog] -[acCfhlnpqtvx] archiv.zip [datei1 datei2 ...]"
    ],
    "full_usage": [
        "Optionen:\n",
        "    -a  --append      Zu Archiv hinzufügen\n",
        "    -c  --create      Archiv erstellen\n",
        "    -C  --directory   In angegebenes Verzeichnis entpacken\n",
        "    -f  --force       Existierende Dateien überschreiben\n",
        "    -h  --help        Diese Hilfe anzeigen\n",
        "    -l  --list        Alle Dateien im Archiv auflisten\n",
        "    -n  --no-clobber  Dateien niemals überschreiben\n",
        "    -p  --print       Eine oder mehr Dateien aus dem Archiv ausgeben",
        "\n",
        "    -q  --quiet       Ruhiger Modus (keine Ausgabe außer Fehler)\n",
        "    -t  --type        Archiv-Typ (gz, tar, tgz, zip)\n",
        "    -v  --verbose     Ausführlicher Modus für Datei-Liste\n",
        "    -x  --extract     Dateien entpacken"
    ],
    "2_options_mutually_exclusive": [
        "Fehler: -%[shortopt1] / --%[longopt1] und ",
        "-%[shortopt2] / --%[longopt2] schließen sich gegenseitig aus!"
    ],
    "5_options_mutually_exclusive": [
        "Fehler: -%[shortopt1] / --%[longopt1], -%[shortopt2] / ",
        "--%[longopt2], -%[shortopt3] / --%[longopt3], ",
        "-%[shortopt4] / --%[longopt4] und\n",
        "        -%[shortopt5] / --%[longopt5] schließen sich gegenseitig aus!"
    ],
    "option_takes_no_argument": "%[prog]: Option --%[opt] nimmt kein Argument",
    "unknown_long_option": "%[prog]: Unbekannte Option: --%[opt]",
    "unknown_option": "%[prog]: Unbekannte Option: -%[opt]",
    "writing_not_supported": [
        "Schreiben von Dateien des Typs %[type] wird (noch) nicht unterstützt!"
    ],
    "failed_to_create_directory": [
        "Fehler beim Erstellen des Verzeichnis %[dir]: %[error]"
    ],
    "failed_to_open_file": "Fehler beim Öffnen der Datei %[file]: %[error]",
    "unknown_archive_type": "Unbekannter Archivtyp: %[type]",
    "failed_to_read_file": "Fehler beim Lesen der Datei %[file]: %[error]",
    "failed_to_write_file": "Fehler beim Schreiben der Datei %[file]: %[error]",