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
|
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 defined(OF_WINDOWS) || defined(OF_DJGPP)
OFArray OF_GENERIC(OFString *) *pathComponents =
[path pathComponents];
if (![path isAbsolutePath]) {
OFString *currentDirectoryPath = [[OFFileManager
defaultManager] currentDirectoryPath];
path = [currentDirectoryPath
path = [pathComponents componentsJoinedByString: @"/"];
if ([[pathComponents firstObject] hasSuffix: @":"])
path = [path stringByPrependingString: @"/"];
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";
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];
|