@@ -27,12 +27,13 @@ #ifdef HAVE_SYS_STAT_H # include #endif #import "OFFile.h" -#import "OFString.h" #import "OFLocalization.h" +#import "OFString.h" +#import "OFURL.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFNotOpenException.h" #import "OFOpenItemFailedException.h" @@ -180,10 +181,17 @@ mode: (OFString *)mode { return [[[self alloc] initWithPath: path mode: mode] autorelease]; } + ++ (instancetype)fileWithURL: (OFURL *)URL + mode: (OFString *)mode +{ + return [[[self alloc] initWithURL: URL + mode: mode] autorelease]; +} + (instancetype)fileWithHandle: (of_file_handle_t)handle { return [[[self alloc] initWithHandle: handle] autorelease]; } @@ -296,10 +304,28 @@ self = [self initWithHandle: handle]; } @catch (id e) { closeHandle(handle); @throw e; } + + return self; +} + +- (instancetype)initWithURL: (OFURL *)URL + mode: (OFString *)mode +{ + @try { + void *pool = objc_autoreleasePoolPush(); + + self = [self initWithPath: [URL fileSystemRepresentation] + mode: mode]; + + objc_autoreleasePoolPop(pool); + } @catch (id e) { + [self release]; + @throw e; + } return self; } - (instancetype)initWithHandle: (of_file_handle_t)handle