Index: src/OFFileManager.h ================================================================== --- src/OFFileManager.h +++ src/OFFileManager.h @@ -32,10 +32,11 @@ # define OF_FILE_MANAGER_SUPPORTS_SYMLINKS #endif @class OFArray OF_GENERIC(ObjectType); @class OFDate; +@class OFURL; /*! * @class OFFileManager OFFileManager.h ObjFW/OFFileManager.h * * @brief A class which provides management for files, e.g. reading contents of @@ -52,10 +53,17 @@ * * @return The path of the current working directory */ - (OFString *)currentDirectoryPath; +/*! + * @brief Returns the URL for the current working directory. + * + * @return The URL of the current working directory + */ +- (OFURL *)currentDirectoryURL; + /*! * @brief Checks whether a file exists at the specified path. * * @param path The path to check * @return A boolean whether there is a file at the specified path Index: src/OFFileManager.m ================================================================== --- src/OFFileManager.m +++ src/OFFileManager.m @@ -33,16 +33,17 @@ #ifdef HAVE_GRP_H # include #endif #import "OFFileManager.h" -#import "OFFile.h" -#import "OFString.h" #import "OFArray.h" #import "OFDate.h" -#import "OFSystemInfo.h" +#import "OFFile.h" #import "OFLocalization.h" +#import "OFString.h" +#import "OFSystemInfo.h" +#import "OFURL.h" #ifdef OF_HAVE_THREADS # import "OFMutex.h" #endif @@ -283,10 +284,25 @@ } return ret; #endif } + +- (OFURL *)currentDirectoryURL +{ + OFMutableURL *URL = [OFMutableURL URL]; + void *pool = objc_autoreleasePoolPush(); + + [URL setScheme: @"file"]; + [URL setPath: [[[self currentDirectoryPath] pathComponents] + componentsJoinedByString: @"/"]]; + [URL makeImmutable]; + + objc_autoreleasePoolPop(pool); + + return URL; +} - (bool)fileExistsAtPath: (OFString *)path { of_stat_t s;