ObjFW  Diff

Differences From Artifact [bb7c13caac]:

To Artifact [13457e7f1d]:


601
602
603
604
605
606
607

608

609




610
611
612
613
614
615
616
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
- (instancetype)initFileURLWithPath: (OFString *)path
{
	bool isDirectory;

	@try {
		void *pool = objc_autoreleasePoolPush();


		isDirectory = ([path hasSuffix: OF_PATH_DELIMITER_STRING] ||

		    [OFURLHandler_file of_directoryExistsAtPath: path]);





		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();
# if OF_PATH_DELIMITER != '/' || defined(OF_WINDOWS) || defined(OF_DJGPP)
		OFArray OF_GENERIC(OFString *) *pathComponents =
		    [path pathComponents];
# endif

# if OF_PATH_DELIMITER != '/'
		path = [pathComponents componentsJoinedByString: @"/"];
# endif

# if defined(OF_WINDOWS) || defined(OF_DJGPP)
		if ([[pathComponents firstObject] hasSuffix: @":"])
			path = [path stringByPrependingString: @"/"];
# endif

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

		_URLEncodedScheme = @"file";

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

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

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







>
|
>

>
>
>
>




















|


<

<

<

<




|








|


<
<







601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
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
- (instancetype)initFileURLWithPath: (OFString *)path
{
	bool isDirectory;

	@try {
		void *pool = objc_autoreleasePoolPush();

#if defined(OF_WINDOWS) || defined(OF_MSDOS)
		isDirectory = ([path hasSuffix: @"\\"] ||
		    [path hasSuffix: @"/"] ||
		    [OFURLHandler_file of_directoryExistsAtPath: path]);
#else
		isDirectory = ([path hasSuffix: @"/"] ||
		    [OFURLHandler_file of_directoryExistsAtPath: path]);
#endif

		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();
# 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];
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989

	path = [self path];

	if ([path hasSuffix: @"/"])
		path = [path substringWithRange:
		    of_range(0, [path length] - 1)];

#ifndef OF_PATH_STARTS_WITH_SLASH
	path = [path substringWithRange: of_range(1, [path length] - 1)];
#endif

#if OF_PATH_DELIMITER != '/'
	path = [OFString pathWithComponents:
	    [path componentsSeparatedByString: @"/"]];
#endif

	[path retain];

	objc_autoreleasePoolPop(pool);







|

<
<
<







971
972
973
974
975
976
977
978
979



980
981
982
983
984
985
986

	path = [self path];

	if ([path hasSuffix: @"/"])
		path = [path substringWithRange:
		    of_range(0, [path length] - 1)];

#if defined(OF_WINDOWS) || defined(OF_MSDOS)
	path = [path substringWithRange: of_range(1, [path length] - 1)];



	path = [OFString pathWithComponents:
	    [path componentsSeparatedByString: @"/"]];
#endif

	[path retain];

	objc_autoreleasePoolPop(pool);