Add NSFileHandle URL initializers.

Also use "instancetype" for all initializers.
This commit is contained in:
Frederik Seiffert 2020-11-17 16:58:29 +01:00
parent d4df4b6d87
commit 88a2e0809f
4 changed files with 55 additions and 14 deletions

View file

@ -32,6 +32,7 @@
#import "Foundation/NSHost.h"
#import "Foundation/NSFileHandle.h"
#import "Foundation/NSPathUtilities.h"
#import "Foundation/NSURL.h"
#import "GNUstepBase/GSTLS.h"
#import "GNUstepBase/NSString+GNUstepBase.h"
#import "GSPrivate.h"
@ -198,6 +199,36 @@ static Class NSFileHandle_ssl_class = nil;
return AUTORELEASE([o initWithNullDevice]);
}
+ (id) fileHandleForReadingFromURL: (NSURL*)url error:(NSError**)error
{
id o = [self fileHandleForReadingAtPath: [url path]];
if (!o && error)
{
*error = [NSError _last];
}
return o;
}
+ (id) fileHandleForWritingToURL: (NSURL*)url error:(NSError**)error
{
id o = [self fileHandleForWritingAtPath: [url path]];
if (!o && error)
{
*error = [NSError _last];
}
return o;
}
+ (id) fileHandleForUpdatingURL: (NSURL*)url error:(NSError**)error
{
id o = [self fileHandleForUpdatingAtPath: [url path]];
if (!o && error)
{
*error = [NSError _last];
}
return o;
}
/**
* Initialize with desc, which can point to either a regular file or
* socket connection.