Overview
Comment: | Add -[OFMutableURL appendPathComponent:] |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
7bf788b164a42a19af61805d9fa4e899 |
User & Date: | js on 2019-04-07 23:05:29 |
Other Links: | manifest | tags |
Context
2019-04-07
| ||
23:15 | Adjust createDirectoryAtURL: to new path handling check-in: e076f9c2ad user: js tags: trunk | |
23:05 | Add -[OFMutableURL appendPathComponent:] check-in: 7bf788b164 user: js tags: trunk | |
22:36 | Improve file URL path handling on Windows/DOS check-in: 9e556d7dca user: js tags: trunk | |
Changes
Modified src/OFMutableURL.h from [3836efd792] to [eff60f9cda].
︙ | ︙ | |||
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | /*! * @brief Creates a new mutable URL. * * @return A new, autoreleased OFMutableURL */ + (instancetype)URL; /*! * @brief Resolves relative sub paths. */ - (void)standardizePath; /*! * @brief Converts the mutable URL to an immutable URL. */ - (void)makeImmutable; @end OF_ASSUME_NONNULL_END | > > > > > > > > > > > > > > > > > | 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | /*! * @brief Creates a new mutable URL. * * @return A new, autoreleased OFMutableURL */ + (instancetype)URL; /*! * @brief Appends the specified path component. * * @param component The component to append */ - (void)appendPathComponent: (OFString *)component; /*! * @brief Appends the specified path component. * * @param component The component to append * @param isDirectory Whether the path is a directory, in which case a slash is * appened if there is no slash yet */ - (void)appendPathComponent: (OFString *)component isDirectory: (bool)isDirectory; /*! * @brief Resolves relative sub paths. */ - (void)standardizePath; /*! * @brief Converts the mutable URL to an immutable URL. */ - (void)makeImmutable; @end OF_ASSUME_NONNULL_END |
Modified src/OFMutableURL.m from [4c8969afe8] to [4d2f137ddf].
︙ | ︙ | |||
15 16 17 18 19 20 21 22 23 24 25 26 27 28 | * file. */ #include "config.h" #import "OFMutableURL.h" #import "OFArray.h" #import "OFNumber.h" #import "OFString.h" #import "OFInvalidFormatException.h" extern void of_url_verify_escaped(OFString *, OFCharacterSet *); | > > > | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | * file. */ #include "config.h" #import "OFMutableURL.h" #import "OFArray.h" #ifdef OF_HAVE_FILES # import "OFFileManager.h" #endif #import "OFNumber.h" #import "OFString.h" #import "OFInvalidFormatException.h" extern void of_url_verify_escaped(OFString *, OFCharacterSet *); |
︙ | ︙ | |||
251 252 253 254 255 256 257 258 259 260 261 262 263 264 | { OFMutableURL *copy = [self mutableCopy]; [copy makeImmutable]; return copy; } - (void)standardizePath { void *pool; OFMutableArray OF_GENERIC(OFString *) *array; bool done = false, endsWithEmpty; OFString *path; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | { OFMutableURL *copy = [self mutableCopy]; [copy makeImmutable]; return copy; } - (void)appendPathComponent: (OFString *)component { [self appendPathComponent: component isDirectory: false]; #ifdef OF_HAVE_FILES if ([_URLEncodedScheme isEqual: @"file"] && ![_URLEncodedPath hasSuffix: @"/"] && [[OFFileManager defaultManager] directoryExistsAtURL: self]) { void *pool = objc_autoreleasePoolPush(); OFString *path = [_URLEncodedPath stringByAppendingString: @"/"]; [_URLEncodedPath release]; _URLEncodedPath = [path retain]; objc_autoreleasePoolPop(pool); } #endif } - (void)appendPathComponent: (OFString *)component isDirectory: (bool)isDirectory { void *pool; OFString *path; if ([component isEqual: @"/"] && [_URLEncodedPath hasSuffix: @"/"]) return; pool = objc_autoreleasePoolPush(); component = [component stringByURLEncodingWithAllowedCharacters: [OFCharacterSet URLPathAllowedCharacterSet]]; #if defined(OF_WINDOWS) || defined(OF_MSDOS) if ([_URLEncodedPath hasSuffix: @"/"] || ([_URLEncodedScheme isEqual: @"file"] && [_URLEncodedPath hasSuffix: @":"])) #else if ([_URLEncodedPath hasSuffix: @"/"]) #endif path = [_URLEncodedPath stringByAppendingString: component]; else path = [_URLEncodedPath stringByAppendingFormat: @"/%@", component]; if (isDirectory && ![path hasSuffix: @"/"]) path = [path stringByAppendingString: @"/"]; [_URLEncodedPath release]; _URLEncodedPath = [path retain]; objc_autoreleasePoolPop(pool); } - (void)standardizePath { void *pool; OFMutableArray OF_GENERIC(OFString *) *array; bool done = false, endsWithEmpty; OFString *path; |
︙ | ︙ |
Modified src/OFURL.m from [a34547048c] to [7aef38f501].
︙ | ︙ | |||
1136 1137 1138 1139 1140 1141 1142 | objc_autoreleasePoolPop(pool); return [path autorelease]; } #endif | | | < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < | | < | < < < < | < < | | | | 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 | objc_autoreleasePoolPop(pool); return [path autorelease]; } #endif - (OFURL *)URLByAppendingPathComponent: (OFString *)component { OFMutableURL *URL = [[self mutableCopy] autorelease]; [URL appendPathComponent: component]; [URL makeImmutable]; return URL; } - (OFURL *)URLByAppendingPathComponent: (OFString *)component isDirectory: (bool)isDirectory { OFMutableURL *URL = [[self mutableCopy] autorelease]; [URL appendPathComponent: component isDirectory: isDirectory]; [URL makeImmutable]; return URL; } - (OFURL *)URLByStandardizingPath { OFMutableURL *URL = [[self mutableCopy] autorelease]; [URL standardizePath]; |
︙ | ︙ |
Modified tests/OFURLTests.m from [ed392bfe35] to [4e831f3a6c].
︙ | ︙ | |||
262 263 264 265 266 267 268 | [[[OFURL URLWithString: @"file:///foo/bar/"] URLByAppendingPathComponent: @"qu?x" isDirectory: false] isEqual: [OFURL URLWithString: @"file:///foo/bar/qu%3Fx"]] && [[[OFURL URLWithString: @"file:///foo/bar/"] URLByAppendingPathComponent: @"qu?x" isDirectory: true] isEqual: | | < < < < < < < < < < < < | 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | [[[OFURL URLWithString: @"file:///foo/bar/"] URLByAppendingPathComponent: @"qu?x" isDirectory: false] isEqual: [OFURL URLWithString: @"file:///foo/bar/qu%3Fx"]] && [[[OFURL URLWithString: @"file:///foo/bar/"] URLByAppendingPathComponent: @"qu?x" isDirectory: true] isEqual: [OFURL URLWithString: @"file:///foo/bar/qu%3Fx/"]]) TEST(@"-[URLByStandardizingPath]", [[[OFURL URLWithString: @"http://foo/bar/.."] URLByStandardizingPath] isEqual: [OFURL URLWithString: @"http://foo/"]] && [[[OFURL URLWithString: @"http://foo/bar/%2E%2E/../qux/"] URLByStandardizingPath] isEqual: |
︙ | ︙ |