Merge pull request #164 from triplef/add-nsfilehandle-url-methods

Add NSFileHandle URL initializers.
This commit is contained in:
rfm 2020-11-18 09:21:13 +00:00 committed by GitHub
commit d27dcfbed6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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.