ObjFW  Check-in [64f72315cd]

Overview
Comment:objfw-unzip: Add "never override" mode.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 64f72315cdfee2b02b00703ce2c5cb3f0c3d43c4cc547e3bd3c4a6443d7daa62
User & Date: js on 2013-11-06 21:11:23
Other Links: manifest | tags
Context
2013-11-06
22:35
Make a few implicit casts explicit. check-in: 62d1b84b30 user: js tags: trunk
21:11
objfw-unzip: Add "never override" mode. check-in: 64f72315cd user: js tags: trunk
20:58
OFZIPArchive: Do not sort -[entries]. check-in: be628bbb84 user: js tags: trunk
Changes

Modified utils/objfw-unzip.m from [b923b772b8] to [b335e42d82].

35
36
37
38
39
40
41
42

43
44
45
46
47
48
49
35
36
37
38
39
40
41

42
43
44
45
46
47
48
49







-
+







	[OFApplication terminate];
}

- (void)extractAllFilesFromArchive: (OFZIPArchive*)archive
{
	OFEnumerator *enumerator = [[archive entries] objectEnumerator];
	OFZIPArchiveEntry *entry;
	bool override = false;
	int_fast8_t override = 0;

	while ((entry = [enumerator nextObject]) != nil) {
		void *pool = objc_autoreleasePoolPush();
		OFString *fileName = [entry fileName];
		OFString *outFileName = [fileName stringByStandardizingPath];
		OFEnumerator *componentEnumerator;
		OFString *component, *directory;
84
85
86
87
88
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
84
85
86
87
88
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







-
+

+
+
+
+
+



-
+



-
+
+

-
+
+
+
+
+
+





-
-
-







		}

		directory = [outFileName stringByDeletingLastPathComponent];
		if (![OFFile directoryExistsAtPath: directory])
			[OFFile createDirectoryAtPath: directory
					createParents: true];

		if ([OFFile fileExistsAtPath: outFileName] && !override) {
		if ([OFFile fileExistsAtPath: outFileName] && override != 1) {
			OFString *line;

			if (override == -1) {
				[of_stdout writeLine: @" skipped"];
				continue;
			}

			do {
				[of_stderr writeFormat:
				    @"\rOverride %@? [ynA] ", fileName];
				    @"\rOverride %@? [ynAN] ", fileName];

				line = [of_stdin readLine];
			} while (![line isEqual: @"y"] &&
			    ![line isEqual: @"n"] && ![line isEqual: @"A"]);
			    ![line isEqual: @"n"] && ![line isEqual: @"N"] &&
			    ![line isEqual: @"A"]);

			if ([line isEqual: @"n"]) {
			if ([line isEqual: @"A"])
				override = 1;
			else if ([line isEqual: @"N"])
				override = -1;

			if ([line isEqual: @"n"] || [line isEqual: @"N"]) {
				[of_stdout writeFormat: @"Skipping %@...\n",
							fileName];
				continue;
			}

			if ([line isEqual: @"A"])
				override = true;

			[of_stdout writeFormat: @"Extracting %@...", fileName];
		}

		stream = [archive streamForReadingFile: fileName];
		output = [OFFile fileWithPath: outFileName
					 mode: @"w"];