Overview
Comment: | OFURL: Move out platform-dependent parts |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
09fb660d549c79943e2f3766f507bae5 |
User & Date: | js on 2020-02-29 19:44:35 |
Other Links: | manifest | tags |
Context
2020-03-01
| ||
08:17 | OFURL: Fix compilation with --disable-files check-in: aaa6195c13 user: js tags: trunk | |
2020-02-29
| ||
19:44 | OFURL: Move out platform-dependent parts check-in: 09fb660d54 user: js tags: trunk | |
16:09 | Move OFProcess to platform subdirectory check-in: 5ca0376aa3 user: js tags: trunk | |
Changes
Modified src/OFString+PathAdditions.h from [be88560228] to [2fb4c588a2].
︙ | ︙ | |||
80 81 82 83 84 85 86 87 88 89 | /*! * @brief Creates a new string by appending a path component. * * @param component The path component to append * @return A new, autoreleased OFString with the path component appended */ - (OFString *)stringByAppendingPathComponent: (OFString *)component; @end OF_ASSUME_NONNULL_END | > > > > > > > | 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | /*! * @brief Creates a new string by appending a path component. * * @param component The path component to append * @return A new, autoreleased OFString with the path component appended */ - (OFString *)stringByAppendingPathComponent: (OFString *)component; - (bool)of_isDirectoryPath; - (OFString *)of_pathToURLPathWithURLEncodedHost: (OFString *__autoreleasing _Nullable *_Nonnull)URLEncodedHost; - (OFString *)of_URLPathToPathWithURLEncodedHost: (nullable OFString *)URLEncodedHost; - (OFString *)of_pathComponentToURLPathComponent; @end OF_ASSUME_NONNULL_END |
Modified src/OFURL.m from [691df6902c] to [b4c5dcf040].
︙ | ︙ | |||
56 57 58 59 60 61 62 | + (OFCharacterSet *)URLPathAllowedCharacterSet; @end @interface OFURLQueryOrFragmentAllowedCharacterSet: OFURLAllowedCharacterSetBase + (OFCharacterSet *)URLQueryOrFragmentAllowedCharacterSet; @end | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | + (OFCharacterSet *)URLPathAllowedCharacterSet; @end @interface OFURLQueryOrFragmentAllowedCharacterSet: OFURLAllowedCharacterSetBase + (OFCharacterSet *)URLQueryOrFragmentAllowedCharacterSet; @end @interface OFInvertedCharacterSetWithoutPercent: OFCharacterSet { OFCharacterSet *_characterSet; bool (*_characterIsMember)(id, SEL, of_unichar_t); } - (instancetype)of_initWithCharacterSet: (OFCharacterSet *)characterSet |
︙ | ︙ | |||
696 697 698 699 700 701 702 | - (instancetype)initFileURLWithPath: (OFString *)path { bool isDirectory; @try { void *pool = objc_autoreleasePoolPush(); | < | < < < < < < < < < < > < < < | < < | | < < < < < < < < < | 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 | - (instancetype)initFileURLWithPath: (OFString *)path { bool isDirectory; @try { void *pool = objc_autoreleasePoolPush(); isDirectory = [path of_isDirectoryPath]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; } self = [self initFileURLWithPath: path isDirectory: isDirectory]; return self; } - (instancetype)initFileURLWithPath: (OFString *)path isDirectory: (bool)isDirectory { self = [super init]; @try { void *pool = objc_autoreleasePoolPush(); OFString *URLEncodedHost = nil; if (!path.absolutePath) { OFString *currentDirectoryPath = [OFFileManager defaultManager].currentDirectoryPath; path = [currentDirectoryPath stringByAppendingPathComponent: path]; path = path.stringByStandardizingPath; } path = [path of_pathToURLPathWithURLEncodedHost: &URLEncodedHost]; _URLEncodedHost = [URLEncodedHost copy]; if (isDirectory && ![path hasSuffix: @"/"]) path = [path stringByAppendingString: @"/"]; _URLEncodedScheme = @"file"; _URLEncodedPath = [[path stringByURLEncodingWithAllowedCharacters: |
︙ | ︙ | |||
928 929 930 931 932 933 934 935 936 937 | { return _URLEncodedPath; } - (OFArray *)pathComponents { void *pool = objc_autoreleasePoolPush(); OFMutableArray *ret; size_t count; | > < | | | < < > > | | < | > | < | | | 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 | { return _URLEncodedPath; } - (OFArray *)pathComponents { void *pool = objc_autoreleasePoolPush(); bool isFile = [_URLEncodedScheme isEqual: @"file"]; OFMutableArray *ret; size_t count; if (isFile) { OFString *path = [_URLEncodedPath of_URLPathToPathWithURLEncodedHost: nil]; ret = [[path.pathComponents mutableCopy] autorelease]; if (![ret.firstObject isEqual: @"/"]) [ret insertObject: @"/" atIndex: 0]; } else ret = [[[_URLEncodedPath componentsSeparatedByString: @"/"] mutableCopy] autorelease]; count = ret.count; if (count > 0 && [ret.firstObject length] == 0) [ret replaceObjectAtIndex: 0 withObject: @"/"]; for (size_t i = 0; i < count; i++) { OFString *component = [ret objectAtIndex: i]; if (isFile) component = [component of_pathComponentToURLPathComponent]; [ret replaceObjectAtIndex: i withObject: component.stringByURLDecoding]; } [ret makeImmutable]; [ret retain]; |
︙ | ︙ | |||
1104 1105 1106 1107 1108 1109 1110 | if (![_URLEncodedScheme isEqual: @"file"]) @throw [OFInvalidArgumentException exception]; if (![_URLEncodedPath hasPrefix: @"/"]) @throw [OFInvalidFormatException exception]; | < | < < < < < < < < < < < < < < < < < < < < | 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 | if (![_URLEncodedScheme isEqual: @"file"]) @throw [OFInvalidArgumentException exception]; if (![_URLEncodedPath hasPrefix: @"/"]) @throw [OFInvalidFormatException exception]; path = [self.path of_URLPathToPathWithURLEncodedHost: _URLEncodedHost]; [path retain]; objc_autoreleasePoolPop(pool); return [path autorelease]; } |
︙ | ︙ |
Modified src/platform/amiga/OFString+PathAdditions.m from [569b6c48d1] to [1ed97b2697].
︙ | ︙ | |||
15 16 17 18 19 20 21 22 23 24 25 26 27 28 | * file. */ #include "config.h" #import "OFString+PathAdditions.h" #import "OFArray.h" #import "OFOutOfRangeException.h" int _OFString_PathAdditions_reference; @implementation OFString (PathAdditions) + (OFString *)pathWithComponents: (OFArray *)components | > | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | * file. */ #include "config.h" #import "OFString+PathAdditions.h" #import "OFArray.h" #import "OFFileURLHandler.h" #import "OFOutOfRangeException.h" int _OFString_PathAdditions_reference; @implementation OFString (PathAdditions) + (OFString *)pathWithComponents: (OFArray *)components |
︙ | ︙ | |||
266 267 268 269 270 271 272 273 | [ret appendString: component]; [ret makeImmutable]; return ret; } } @end | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | [ret appendString: component]; [ret makeImmutable]; return ret; } } - (bool)of_isDirectoryPath { return ([self hasSuffix: @"/"] || [self hasSuffix: @":"] || [OFFileURLHandler of_directoryExistsAtPath: self]); } - (OFString *)of_pathToURLPathWithURLEncodedHost: (OFString **)URLEncodedHost { OFArray OF_GENERIC(OFString *) *components = self.pathComponents; OFMutableString *ret = [OFMutableString string]; for (OFString *component in components) { if (component.length == 0) continue; if ([component isEqual: @"/"]) [ret appendString: @"/.."]; else { [ret appendString: @"/"]; [ret appendString: component]; } } [ret makeImmutable]; return ret; } - (OFString *)of_URLPathToPathWithURLEncodedHost: (OFString *)URLEncodedHost { OFString *path = self; if (path.length > 1 && [path hasSuffix: @"/"]) path = [path substringWithRange: of_range(0, path.length - 1)]; OFMutableArray OF_GENERIC(OFString *) *components; size_t count; path = [path substringWithRange: of_range(1, path.length - 1)]; components = [[[path componentsSeparatedByString: @"/"] mutableCopy] autorelease]; count = components.count; for (size_t i = 0; i < count; i++) { OFString *component = [components objectAtIndex: i]; if ([component isEqual: @"."]) { [components removeObjectAtIndex: i]; count--; i--; continue; } if ([component isEqual: @".."]) [components replaceObjectAtIndex: i withObject: @"/"]; } return [OFString pathWithComponents: components]; } - (OFString *)of_pathComponentToURLPathComponent { return self; } @end |
Modified src/platform/libfat/OFString+PathAdditions.m from [fc28106dee] to [b5e9ff2888].
︙ | ︙ | |||
15 16 17 18 19 20 21 22 23 24 25 26 27 28 | * file. */ #include "config.h" #import "OFString+PathAdditions.h" #import "OFArray.h" #import "OFOutOfRangeException.h" int _OFString_PathAdditions_reference; @implementation OFString (PathAdditions) + (OFString *)pathWithComponents: (OFArray *)components | > | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | * file. */ #include "config.h" #import "OFString+PathAdditions.h" #import "OFArray.h" #import "OFFileURLHandler.h" #import "OFOutOfRangeException.h" int _OFString_PathAdditions_reference; @implementation OFString (PathAdditions) + (OFString *)pathWithComponents: (OFArray *)components |
︙ | ︙ | |||
312 313 314 315 316 317 318 319 | [ret appendString: component]; [ret makeImmutable]; return ret; } } @end | > > > > > > > > > > > > > > > > > > > > > > > > > > | 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | [ret appendString: component]; [ret makeImmutable]; return ret; } } - (bool)of_isDirectoryPath { return ([self hasSuffix: @"/"] || [OFFileURLHandler of_directoryExistsAtPath: self]); } - (OFString *)of_pathToURLPathWithURLEncodedHost: (OFString **)URLEncodedHost { return [self stringByPrependingString: @"/"]; } - (OFString *)of_URLPathToPathWithURLEncodedHost: (OFString *)URLEncodedHost { OFString *path = self; if (path.length > 1 && [path hasSuffix: @"/"]) path = [path substringWithRange: of_range(0, path.length - 1)]; return [path substringWithRange: of_range(1, path.length - 1)]; } - (OFString *)of_pathComponentToURLPathComponent { return self; } @end |
Modified src/platform/posix/OFString+PathAdditions.m from [3ec0045bce] to [e173df7149].
︙ | ︙ | |||
15 16 17 18 19 20 21 22 23 24 25 26 27 28 | * file. */ #include "config.h" #import "OFString+PathAdditions.h" #import "OFArray.h" #import "OFOutOfRangeException.h" int _OFString_PathAdditions_reference; @implementation OFString (PathAdditions) + (OFString *)pathWithComponents: (OFArray *)components | > | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | * file. */ #include "config.h" #import "OFString+PathAdditions.h" #import "OFArray.h" #import "OFFileURLHandler.h" #import "OFOutOfRangeException.h" int _OFString_PathAdditions_reference; @implementation OFString (PathAdditions) + (OFString *)pathWithComponents: (OFArray *)components |
︙ | ︙ | |||
312 313 314 315 316 317 318 319 | [ret appendString: component]; [ret makeImmutable]; return ret; } } @end | > > > > > > > > > > > > > > > > > > > > > > > > > > | 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | [ret appendString: component]; [ret makeImmutable]; return ret; } } - (bool)of_isDirectoryPath { return ([self hasSuffix: @"/"] || [OFFileURLHandler of_directoryExistsAtPath: self]); } - (OFString *)of_pathToURLPathWithURLEncodedHost: (OFString **)URLEncodedHost { return self; } - (OFString *)of_URLPathToPathWithURLEncodedHost: (OFString *)URLEncodedHost { OFString *path = self; if (path.length > 1 && [path hasSuffix: @"/"]) path = [path substringWithRange: of_range(0, path.length - 1)]; return path; } - (OFString *)of_pathComponentToURLPathComponent { return self; } @end |
Modified src/platform/windows/OFString+PathAdditions.m from [c04745b26d] to [c654a7d368].
︙ | ︙ | |||
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | * parts! */ #include "config.h" #import "OFString+PathAdditions.h" #import "OFArray.h" #import "OFOutOfRangeException.h" int _OFString_PathAdditions_reference; @implementation OFString (PathAdditions) + (OFString *)pathWithComponents: (OFArray *)components { | > > > | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | * parts! */ #include "config.h" #import "OFString+PathAdditions.h" #import "OFArray.h" #import "OFFileURLHandler.h" #import "OFURL.h" #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" int _OFString_PathAdditions_reference; @implementation OFString (PathAdditions) + (OFString *)pathWithComponents: (OFArray *)components { |
︙ | ︙ | |||
314 315 316 317 318 319 320 321 | [ret appendString: component]; [ret makeImmutable]; return ret; } } @end | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 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 378 379 380 381 382 383 384 385 | [ret appendString: component]; [ret makeImmutable]; return ret; } } - (bool)of_isDirectoryPath { return ([self hasSuffix: @"\\"] || [self hasSuffix: @"/"] || [OFFileURLHandler of_directoryExistsAtPath: self]); } - (OFString *)of_pathToURLPathWithURLEncodedHost: (OFString **)URLEncodedHost { OFString *path = self; if ([path hasPrefix: @"\\\\"]) { OFArray *components = path.pathComponents; if (components.count < 2) @throw [OFInvalidFormatException exception]; *URLEncodedHost = [[components objectAtIndex: 1] stringByURLEncodingWithAllowedCharacters: [OFCharacterSet URLHostAllowedCharacterSet]]; path = [OFString pathWithComponents: [components objectsInRange: of_range(2, components.count - 2)]]; } path = [path stringByReplacingOccurrencesOfString: @"\\" withString: @"/"]; path = [path stringByPrependingString: @"/"]; return path; } - (OFString *)of_URLPathToPathWithURLEncodedHost: (OFString *)URLEncodedHost { OFString *path = self; if (path.length > 1 && [path hasSuffix: @"/"] && ![path hasSuffix: @":/"]) path = [path substringWithRange: of_range(0, path.length - 1)]; path = [path substringWithRange: of_range(1, path.length - 1)]; path = [path stringByReplacingOccurrencesOfString: @"/" withString: @"\\"]; if (URLEncodedHost != nil) { OFString *host = [URLEncodedHost stringByURLDecoding]; if (path.length == 0) path = [OFString stringWithFormat: @"\\\\%@", host]; else path = [OFString stringWithFormat: @"\\\\%@\\%@", host, path]; } return path; } - (OFString *)of_pathComponentToURLPathComponent { return [self stringByReplacingOccurrencesOfString: @"\\" withString: @"/"]; } @end |