Index: src/OFURL.h ================================================================== --- src/OFURL.h +++ src/OFURL.h @@ -102,10 +102,18 @@ * @return A new, autoreleased OFURL */ + (instancetype)URLWithString: (OFString*)string relativeToURL: (OFURL*)URL; +/*! + * @brief Creates a new URL with the specified local file path. + * + * @param path The local file path + * @return A new, autoreleased OFURL + */ ++ (instancetype)fileURLWithPath: (OFString*)path; + /*! * @brief Initializes an already allocated OFURL with the specified string. * * @param string A string describing a URL * @return An initialized OFURL Index: src/OFURL.m ================================================================== --- src/OFURL.m +++ src/OFURL.m @@ -48,10 +48,23 @@ relativeToURL: (OFURL*)URL { return [[[self alloc] initWithString: string relativeToURL: URL] autorelease]; } + ++ (instancetype)fileURLWithPath: (OFString*)path +{ + OFURL *URL = [OFURL URL]; + void *pool = objc_autoreleasePoolPush(); + + [URL setScheme: @"file"]; + [URL setPath: [[path pathComponents] componentsJoinedByString: @"/"]]; + + objc_autoreleasePoolPop(pool); + + return URL; +} - initWithString: (OFString*)string { char *UTF8String, *UTF8String2 = NULL;