ObjFW  Check-in [5c4470fb42]

Overview
Comment:OFLHAArchiveEntry: Improve directory name parsing

This now works with UTF-8 encoded directory names.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 5c4470fb42acd6dfee4b2bdc688009f6de1f463d0ffc7366191b2ffc7012e70b
User & Date: js on 2018-05-27 00:48:16
Other Links: manifest | tags
Context
2018-05-27
07:32
OFLHAArchiveEntry: Keep the method as a string check-in: 1a6e3816c1 user: js tags: trunk
00:48
OFLHAArchiveEntry: Improve directory name parsing check-in: 5c4470fb42 user: js tags: trunk
00:21
OFLHAArchiveEntry: Parse more extensions check-in: 56d02a1ac5 user: js tags: trunk
Changes

Modified src/OFLHAArchiveEntry.m from [62cdc3890f] to [e8d94333d8].

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
72
73
74
75
76
}

static void
parseDirectoryNameExtension(OFLHAArchiveEntry *entry, OFData *extension,
    of_string_encoding_t encoding)
{
	void *pool = objc_autoreleasePoolPush();


	OFString *tmp = [OFString
	    stringWithCString: (char *)[extension items] + 1
		     encoding: encoding



		       length: [extension count] - 1];
	OFString *separator = [OFString stringWithCString: "\xFF"
						 encoding: encoding
						   length: 1];

	if (![tmp hasSuffix: separator])
		@throw [OFInvalidFormatException exception];


	tmp = [tmp stringByReplacingOccurrencesOfString: separator
					     withString: @"/"];


	[entry->_directoryName release];
	entry->_directoryName = nil;

	entry->_directoryName = [tmp copy];

	objc_autoreleasePoolPop(pool);
}

static void
parseCommentExtension(OFLHAArchiveEntry *entry, OFData *extension,
    of_string_encoding_t encoding)







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

|
<
>

<
<
>




|







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
72
73
74
75
76
77
78
79
80
}

static void
parseDirectoryNameExtension(OFLHAArchiveEntry *entry, OFData *extension,
    of_string_encoding_t encoding)
{
	void *pool = objc_autoreleasePoolPush();
	OFMutableData *data = [[extension mutableCopy] autorelease];
	char *items = [data items];
	size_t count = [data count];
	OFMutableString *directoryName;

	for (size_t i = 1; i < count; i++)
		if (items[i] == '\xFF')
			items[i] = '/';

	directoryName = [OFMutableString stringWithCString: items + 1
						  encoding: encoding
						    length: count - 1];

	if (![directoryName hasSuffix: @"/"])

		[directoryName appendString: @"/"];



	[directoryName makeImmutable];

	[entry->_directoryName release];
	entry->_directoryName = nil;

	entry->_directoryName = [directoryName copy];

	objc_autoreleasePoolPop(pool);
}

static void
parseCommentExtension(OFLHAArchiveEntry *entry, OFData *extension,
    of_string_encoding_t encoding)