@@ -629,17 +629,18 @@ } - (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 - OFURL *currentDirectoryURL; # if OF_PATH_DELIMITER != '/' path = [pathComponents componentsJoinedByString: @"/"]; # endif @@ -649,15 +650,24 @@ # endif if (isDirectory && ![path hasSuffix: OF_PATH_DELIMITER_STRING]) path = [path stringByAppendingString: @"/"]; - currentDirectoryURL = - [[OFFileManager defaultManager] currentDirectoryURL]; + _URLEncodedScheme = @"file"; - self = [self initWithString: path - relativeToURL: currentDirectoryURL]; + if (![path hasPrefix: @"/"]) { + OFString *currentDirectoryPath = [[OFFileManager + defaultManager] currentDirectoryPath]; + + path = [OFString stringWithFormat: + @"%@/%@", currentDirectoryPath, path]; + path = [path stringByStandardizingURLPath]; + } + + _URLEncodedPath = [[path + stringByURLEncodingWithAllowedCharacters: + [OFCharacterSet URLPathAllowedCharacterSet]] copy]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e;