ObjFW  Check-in [13f0321eff]

Overview
Comment:Rename schemes for archive IRI handlers

Some names are too generic and might cause conflicts (e.g. zoo).

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 13f0321efff153790c9f48d22a5de78c35a4d97d98298efb6239770261b4711c
User & Date: js on 2024-03-03 19:42:33
Other Links: manifest | tags
Context
2024-03-04
01:21
Rename schemes for archive IRI handlers back check-in: 34a3e817b3 user: js tags: trunk
2024-03-03
19:54
ofarc: Add support for creating Zoo archives check-in: 780132a941 user: js tags: trunk
19:42
Rename schemes for archive IRI handlers check-in: 13f0321eff user: js tags: trunk
19:38
Add IRI handler for Zoo archives check-in: 4e1846598b user: js tags: trunk
Changes

Modified src/OFArchiveIRIHandler.m from [bfc9deb3f2] to [4c05cb75e3].

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
132
133
134
135
136
137
138
	archiveIRI = [OFIRI IRIWithString:
	    [percentEncodedPath substringWithRange: OFMakeRange(0, pos)]
	    .stringByRemovingPercentEncoding];
	path = [percentEncodedPath substringWithRange:
	    OFMakeRange(pos + 1, percentEncodedPath.length - pos - 1)]
	    .stringByRemovingPercentEncoding;

	if ([scheme isEqual: @"lha"]) {
		OFLHAArchive *archive = [OFLHAArchive archiveWithIRI: archiveIRI
								mode: @"r"];
		OFLHAArchiveEntry *entry;

		while ((entry = [archive nextEntry]) != nil) {
			if ([entry.fileName isEqual: path]) {
				stream = [archive streamForReadingCurrentEntry];
				goto end;
			}
		}

		@throw [OFOpenItemFailedException exceptionWithIRI: IRI
							      mode: mode
							     errNo: ENOENT];
	} else if ([scheme isEqual: @"tar"]) {
		OFTarArchive *archive = [OFTarArchive archiveWithIRI: archiveIRI
								mode: @"r"];
		OFTarArchiveEntry *entry;

		while ((entry = [archive nextEntry]) != nil) {
			if ([entry.fileName isEqual: path]) {
				stream = [archive streamForReadingCurrentEntry];
				goto end;
			}
		}

		@throw [OFOpenItemFailedException exceptionWithIRI: IRI
							      mode: mode
							     errNo: ENOENT];
	} else if ([scheme isEqual: @"zip"]) {
		OFZIPArchive *archive = [OFZIPArchive archiveWithIRI: archiveIRI
								mode: @"r"];

		stream = [archive streamForReadingFile: path];
	} else if ([scheme isEqual: @"zoo"]) {
		OFZooArchive *archive = [OFZooArchive archiveWithIRI: archiveIRI
								mode: @"r"];
		OFZooArchiveEntry *entry;

		while ((entry = [archive nextEntry]) != nil) {
			if ([entry.fileName isEqual: path]) {
				stream = [archive streamForReadingCurrentEntry];







|














|














|




|







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
132
133
134
135
136
137
138
	archiveIRI = [OFIRI IRIWithString:
	    [percentEncodedPath substringWithRange: OFMakeRange(0, pos)]
	    .stringByRemovingPercentEncoding];
	path = [percentEncodedPath substringWithRange:
	    OFMakeRange(pos + 1, percentEncodedPath.length - pos - 1)]
	    .stringByRemovingPercentEncoding;

	if ([scheme isEqual: @"lha-archive"]) {
		OFLHAArchive *archive = [OFLHAArchive archiveWithIRI: archiveIRI
								mode: @"r"];
		OFLHAArchiveEntry *entry;

		while ((entry = [archive nextEntry]) != nil) {
			if ([entry.fileName isEqual: path]) {
				stream = [archive streamForReadingCurrentEntry];
				goto end;
			}
		}

		@throw [OFOpenItemFailedException exceptionWithIRI: IRI
							      mode: mode
							     errNo: ENOENT];
	} else if ([scheme isEqual: @"tar-archive"]) {
		OFTarArchive *archive = [OFTarArchive archiveWithIRI: archiveIRI
								mode: @"r"];
		OFTarArchiveEntry *entry;

		while ((entry = [archive nextEntry]) != nil) {
			if ([entry.fileName isEqual: path]) {
				stream = [archive streamForReadingCurrentEntry];
				goto end;
			}
		}

		@throw [OFOpenItemFailedException exceptionWithIRI: IRI
							      mode: mode
							     errNo: ENOENT];
	} else if ([scheme isEqual: @"zip-archive"]) {
		OFZIPArchive *archive = [OFZIPArchive archiveWithIRI: archiveIRI
								mode: @"r"];

		stream = [archive streamForReadingFile: path];
	} else if ([scheme isEqual: @"zoo-archive"]) {
		OFZooArchive *archive = [OFZooArchive archiveWithIRI: archiveIRI
								mode: @"r"];
		OFZooArchiveEntry *entry;

		while ((entry = [archive nextEntry]) != nil) {
			if ([entry.fileName isEqual: path]) {
				stream = [archive streamForReadingCurrentEntry];

Modified src/OFIRIHandler.m from [16ea63c925] to [43b582a6b5].

66
67
68
69
70
71
72
73

74

75

76

77
78
79
80
81
82
83
	[self registerClass: [OFFileIRIHandler class] forScheme: @"file"];
#endif
#if defined(OF_HAVE_SOCKETS) && defined(OF_HAVE_THREADS)
	[self registerClass: [OFHTTPIRIHandler class] forScheme: @"http"];
	[self registerClass: [OFHTTPIRIHandler class] forScheme: @"https"];
#endif
	[self registerClass: [OFArchiveIRIHandler class] forScheme: @"gzip"];
	[self registerClass: [OFArchiveIRIHandler class] forScheme: @"lha"];

	[self registerClass: [OFArchiveIRIHandler class] forScheme: @"tar"];

	[self registerClass: [OFArchiveIRIHandler class] forScheme: @"zip"];

	[self registerClass: [OFArchiveIRIHandler class] forScheme: @"zoo"];

}

+ (bool)registerClass: (Class)class forScheme: (OFString *)scheme
{
#ifdef OF_HAVE_THREADS
	[mutex lock];
	@try {







|
>
|
>
|
>
|
>







66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
	[self registerClass: [OFFileIRIHandler class] forScheme: @"file"];
#endif
#if defined(OF_HAVE_SOCKETS) && defined(OF_HAVE_THREADS)
	[self registerClass: [OFHTTPIRIHandler class] forScheme: @"http"];
	[self registerClass: [OFHTTPIRIHandler class] forScheme: @"https"];
#endif
	[self registerClass: [OFArchiveIRIHandler class] forScheme: @"gzip"];
	[self registerClass: [OFArchiveIRIHandler class]
		  forScheme: @"lha-archive"];
	[self registerClass: [OFArchiveIRIHandler class]
		  forScheme: @"tar-archive"];
	[self registerClass: [OFArchiveIRIHandler class]
		  forScheme: @"zip-archive"];
	[self registerClass: [OFArchiveIRIHandler class]
		  forScheme: @"zoo-archive"];
}

+ (bool)registerClass: (Class)class forScheme: (OFString *)scheme
{
#ifdef OF_HAVE_THREADS
	[mutex lock];
	@try {

Modified src/OFLHAArchive.m from [7fd2208cb9] to [de067758a4].

93
94
95
96
97
98
99
100

101
102
103
104
105
106
107
+ (instancetype)archiveWithIRI: (OFIRI *)IRI mode: (OFString *)mode
{
	return [[[self alloc] initWithIRI: IRI mode: mode] autorelease];
}

+ (OFIRI *)IRIForFilePath: (OFString *)path inArchiveWithIRI: (OFIRI *)IRI
{
	return OFArchiveIRIHandlerIRIForFileInArchive(@"lha", path, IRI);

}

- (instancetype)init
{
	OF_INVALID_INIT_METHOD
}








|
>







93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
+ (instancetype)archiveWithIRI: (OFIRI *)IRI mode: (OFString *)mode
{
	return [[[self alloc] initWithIRI: IRI mode: mode] autorelease];
}

+ (OFIRI *)IRIForFilePath: (OFString *)path inArchiveWithIRI: (OFIRI *)IRI
{
	return OFArchiveIRIHandlerIRIForFileInArchive(
	    @"lha-archive", path, IRI);
}

- (instancetype)init
{
	OF_INVALID_INIT_METHOD
}

Modified src/OFTarArchive.m from [23e0c065c8] to [1855b6b9b8].

84
85
86
87
88
89
90
91

92
93
94
95
96
97
98
+ (instancetype)archiveWithIRI: (OFIRI *)IRI mode: (OFString *)mode
{
	return [[[self alloc] initWithIRI: IRI mode: mode] autorelease];
}

+ (OFIRI *)IRIForFilePath: (OFString *)path inArchiveWithIRI: (OFIRI *)IRI
{
	return OFArchiveIRIHandlerIRIForFileInArchive(@"tar", path, IRI);

}

- (instancetype)init
{
	OF_INVALID_INIT_METHOD
}








|
>







84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
+ (instancetype)archiveWithIRI: (OFIRI *)IRI mode: (OFString *)mode
{
	return [[[self alloc] initWithIRI: IRI mode: mode] autorelease];
}

+ (OFIRI *)IRIForFilePath: (OFString *)path inArchiveWithIRI: (OFIRI *)IRI
{
	return OFArchiveIRIHandlerIRIForFileInArchive(
	    @"tar-archive", path, IRI);
}

- (instancetype)init
{
	OF_INVALID_INIT_METHOD
}

Modified src/OFZIPArchive.m from [1f22a87e08] to [8040666849].

195
196
197
198
199
200
201
202

203
204
205
206
207
208
209
+ (instancetype)archiveWithIRI: (OFIRI *)IRI mode: (OFString *)mode
{
	return [[[self alloc] initWithIRI: IRI mode: mode] autorelease];
}

+ (OFIRI *)IRIForFilePath: (OFString *)path inArchiveWithIRI: (OFIRI *)IRI
{
	return OFArchiveIRIHandlerIRIForFileInArchive(@"zip", path, IRI);

}

- (instancetype)init
{
	OF_INVALID_INIT_METHOD
}








|
>







195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
+ (instancetype)archiveWithIRI: (OFIRI *)IRI mode: (OFString *)mode
{
	return [[[self alloc] initWithIRI: IRI mode: mode] autorelease];
}

+ (OFIRI *)IRIForFilePath: (OFString *)path inArchiveWithIRI: (OFIRI *)IRI
{
	return OFArchiveIRIHandlerIRIForFileInArchive(
	    @"zip-archive", path, IRI);
}

- (instancetype)init
{
	OF_INVALID_INIT_METHOD
}

Modified src/OFZooArchive.m from [1cb73fe5ae] to [412525e4b5].

101
102
103
104
105
106
107
108

109
110
111
112
113
114
115
+ (instancetype)archiveWithIRI: (OFIRI *)IRI mode: (OFString *)mode
{
	return [[[self alloc] initWithIRI: IRI mode: mode] autorelease];
}

+ (OFIRI *)IRIForFilePath: (OFString *)path inArchiveWithIRI: (OFIRI *)IRI
{
	return OFArchiveIRIHandlerIRIForFileInArchive(@"zoo", path, IRI);

}

- (instancetype)init
{
	OF_INVALID_INIT_METHOD
}








|
>







101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
+ (instancetype)archiveWithIRI: (OFIRI *)IRI mode: (OFString *)mode
{
	return [[[self alloc] initWithIRI: IRI mode: mode] autorelease];
}

+ (OFIRI *)IRIForFilePath: (OFString *)path inArchiveWithIRI: (OFIRI *)IRI
{
	return OFArchiveIRIHandlerIRIForFileInArchive(
	    @"zoo-archive", path, IRI);
}

- (instancetype)init
{
	OF_INVALID_INIT_METHOD
}