ObjFW  Check-in [88d0ccf804]

Overview
Comment:Clean up -[OFURL initFileURLWithPath:isDirectory:]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 88d0ccf804c5c786be76ac07426388887ac5bd333e020eced49c5901a1766752
User & Date: js on 2018-03-11 21:59:22
Other Links: manifest | tags
Context
2018-03-11
23:11
OFHTTPClient: Throw if socket got closed too early check-in: 69c2ca803a user: js tags: trunk
21:59
Clean up -[OFURL initFileURLWithPath:isDirectory:] check-in: 88d0ccf804 user: js tags: trunk
21:43
Add -[OFString isAbsolutePath] check-in: c6299422a1 user: js tags: trunk
Changes

Modified src/OFURL.m from [13457e7f1d] to [6014ddabe8].

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
666
667
668
669
670
671
672
673
- (instancetype)initFileURLWithPath: (OFString *)path
			isDirectory: (bool)isDirectory
{
	self = [super init];

	@try {
		void *pool = objc_autoreleasePoolPush();
# if defined(OF_WINDOWS) || defined(OF_DJGPP)

		OFArray OF_GENERIC(OFString *) *pathComponents =
		    [path pathComponents];


		path = [pathComponents componentsJoinedByString: @"/"];


		if ([[pathComponents firstObject] hasSuffix: @":"])



			path = [path stringByPrependingString: @"/"];
# endif

		if (isDirectory && ![path hasSuffix: @"/"])
			path = [path stringByAppendingString: @"/"];

		_URLEncodedScheme = @"file";

		if (![path hasPrefix: @"/"]) {
			OFString *currentDirectoryPath = [[OFFileManager
			    defaultManager] currentDirectoryPath];

# if defined(OF_WINDOWS) || defined(OF_DJGPP)
			currentDirectoryPath = [[currentDirectoryPath
			    pathComponents] componentsJoinedByString: @"/"];
			currentDirectoryPath = [currentDirectoryPath
			    stringByPrependingString: @"/"];
# endif

			path = [currentDirectoryPath
			    stringByAppendingURLPathComponent: path];
			path = [path stringByStandardizingURLPath];
		}

		_URLEncodedPath = [[path
		    stringByURLEncodingWithAllowedCharacters:
		    [OFCharacterSet URLPathAllowedCharacterSet]] copy];

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];







|
>
|
|

>
|
>
|
|
>
>
>
|






<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







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
- (instancetype)initFileURLWithPath: (OFString *)path
			isDirectory: (bool)isDirectory
{
	self = [super init];

	@try {
		void *pool = objc_autoreleasePoolPush();

		if (![path isAbsolutePath]) {
			OFString *currentDirectoryPath = [[OFFileManager
			    defaultManager] currentDirectoryPath];

			path = [currentDirectoryPath
			    stringByAppendingPathComponent: path];
			path = [path stringByStandardizingPath];
		}

# if defined(OF_WINDOWS) || defined(OF_DJGPP)
		path = [path stringByReplacingOccurrencesOfString: @"\\"
						       withString: @"/"];
		path = [path stringByPrependingString: @"/"];
# endif

		if (isDirectory && ![path hasSuffix: @"/"])
			path = [path stringByAppendingString: @"/"];

		_URLEncodedScheme = @"file";

















		_URLEncodedPath = [[path
		    stringByURLEncodingWithAllowedCharacters:
		    [OFCharacterSet URLPathAllowedCharacterSet]] copy];

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];