mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
implement methods to create a stream to read from a URL
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@40420 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
315b63a235
commit
08d08634c8
3 changed files with 54 additions and 0 deletions
|
@ -160,6 +160,12 @@ typedef NSUInteger NSStreamEvent;
|
|||
*/
|
||||
+ (id) inputStreamWithFileAtPath: (NSString *)path;
|
||||
|
||||
/**
|
||||
* Creates and returns an initialized NSInputStream object that reads data from
|
||||
* the specified URL.
|
||||
*/
|
||||
+ (id) inputStreamWithURL: (NSURL *)url;
|
||||
|
||||
/**
|
||||
* Returns a pointer to the read buffer in buffer and, by reference, the number
|
||||
* of bytes available in len.
|
||||
|
@ -184,6 +190,12 @@ typedef NSUInteger NSStreamEvent;
|
|||
*/
|
||||
- (id) initWithFileAtPath: (NSString *)path;
|
||||
|
||||
/**
|
||||
* Returns an initialized NSInputStream object for reading from the
|
||||
* specified URL.
|
||||
*/
|
||||
- (id) initWithURL: (NSURL *)url;
|
||||
|
||||
/**
|
||||
* Reads up to len bytes into buffer, returning the actual number of bytes read.
|
||||
*/
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#import "Foundation/NSValue.h"
|
||||
#import "Foundation/NSHost.h"
|
||||
#import "Foundation/NSByteOrder.h"
|
||||
#import "Foundation/NSURL.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
|
||||
#import "../GSPrivate.h"
|
||||
|
@ -507,6 +508,15 @@
|
|||
return AUTORELEASE([[GSFileInputStream alloc] initWithFileAtPath: path]);
|
||||
}
|
||||
|
||||
+ (id) inputStreamWithURL: (NSURL *)url
|
||||
{
|
||||
if ([url isFileURL])
|
||||
{
|
||||
return [self inputStreamWithFileAtPath: [url path]];
|
||||
}
|
||||
return [self inputStreamWithData: [url resourceDataUsingCache: YES]];
|
||||
}
|
||||
|
||||
- (BOOL) getBuffer: (uint8_t **)buffer length: (NSUInteger *)len
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
|
@ -531,6 +541,17 @@
|
|||
return [[GSFileInputStream alloc] initWithFileAtPath: path];
|
||||
}
|
||||
|
||||
- (id) initWithURL: (NSURL *)url
|
||||
{
|
||||
DESTROY(self);
|
||||
if ([url isFileURL])
|
||||
{
|
||||
return [[GSFileInputStream alloc] initWithFileAtPath: [url path]];
|
||||
}
|
||||
return [[GSDataInputStream alloc]
|
||||
initWithData: [url resourceDataUsingCache: YES]];
|
||||
}
|
||||
|
||||
- (NSInteger) read: (uint8_t *)buffer maxLength: (NSUInteger)len
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#import "Foundation/NSHost.h"
|
||||
#import "Foundation/NSProcessInfo.h"
|
||||
#import "Foundation/NSByteOrder.h"
|
||||
#import "Foundation/NSURL.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
|
||||
#import "../GSPrivate.h"
|
||||
|
@ -1202,6 +1203,15 @@ done:
|
|||
return AUTORELEASE([[GSFileInputStream alloc] initWithFileAtPath: path]);
|
||||
}
|
||||
|
||||
+ (id) inputStreamWithURL: (NSURL *)url
|
||||
{
|
||||
if ([url isFileURL])
|
||||
{
|
||||
return [self inputStreamWithFileAtPath: [url path]];
|
||||
}
|
||||
return [self inputStreamWithData: [url resourceDataUsingCache: YES]];
|
||||
}
|
||||
|
||||
- (BOOL) getBuffer: (uint8_t **)buffer length: (NSUInteger *)len
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
|
@ -1226,6 +1236,17 @@ done:
|
|||
return [[GSFileInputStream alloc] initWithFileAtPath: path];
|
||||
}
|
||||
|
||||
- (id) initWithURL: (NSURL *)url
|
||||
{
|
||||
DESTROY(self);
|
||||
if ([url isFileURL])
|
||||
{
|
||||
return [[GSFileInputStream alloc] initWithFileAtPath: [url path]];
|
||||
}
|
||||
return [[GSDataInputStream alloc]
|
||||
initWithData: [url resourceDataUsingCache: YES]];
|
||||
}
|
||||
|
||||
- (NSInteger) read: (uint8_t *)buffer maxLength: (NSUInteger)len
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
|
|
Loading…
Reference in a new issue