mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +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
173079f8f5
commit
71d1d5c42b
3 changed files with 54 additions and 0 deletions
|
@ -160,6 +160,12 @@ typedef NSUInteger NSStreamEvent;
|
||||||
*/
|
*/
|
||||||
+ (id) inputStreamWithFileAtPath: (NSString *)path;
|
+ (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
|
* Returns a pointer to the read buffer in buffer and, by reference, the number
|
||||||
* of bytes available in len.
|
* of bytes available in len.
|
||||||
|
@ -184,6 +190,12 @@ typedef NSUInteger NSStreamEvent;
|
||||||
*/
|
*/
|
||||||
- (id) initWithFileAtPath: (NSString *)path;
|
- (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.
|
* Reads up to len bytes into buffer, returning the actual number of bytes read.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
#import "Foundation/NSValue.h"
|
#import "Foundation/NSValue.h"
|
||||||
#import "Foundation/NSHost.h"
|
#import "Foundation/NSHost.h"
|
||||||
#import "Foundation/NSByteOrder.h"
|
#import "Foundation/NSByteOrder.h"
|
||||||
|
#import "Foundation/NSURL.h"
|
||||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||||
|
|
||||||
#import "../GSPrivate.h"
|
#import "../GSPrivate.h"
|
||||||
|
@ -507,6 +508,15 @@
|
||||||
return AUTORELEASE([[GSFileInputStream alloc] initWithFileAtPath: path]);
|
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
|
- (BOOL) getBuffer: (uint8_t **)buffer length: (NSUInteger *)len
|
||||||
{
|
{
|
||||||
[self subclassResponsibility: _cmd];
|
[self subclassResponsibility: _cmd];
|
||||||
|
@ -531,6 +541,17 @@
|
||||||
return [[GSFileInputStream alloc] initWithFileAtPath: path];
|
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
|
- (NSInteger) read: (uint8_t *)buffer maxLength: (NSUInteger)len
|
||||||
{
|
{
|
||||||
[self subclassResponsibility: _cmd];
|
[self subclassResponsibility: _cmd];
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#import "Foundation/NSHost.h"
|
#import "Foundation/NSHost.h"
|
||||||
#import "Foundation/NSProcessInfo.h"
|
#import "Foundation/NSProcessInfo.h"
|
||||||
#import "Foundation/NSByteOrder.h"
|
#import "Foundation/NSByteOrder.h"
|
||||||
|
#import "Foundation/NSURL.h"
|
||||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||||
|
|
||||||
#import "../GSPrivate.h"
|
#import "../GSPrivate.h"
|
||||||
|
@ -1202,6 +1203,15 @@ done:
|
||||||
return AUTORELEASE([[GSFileInputStream alloc] initWithFileAtPath: path]);
|
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
|
- (BOOL) getBuffer: (uint8_t **)buffer length: (NSUInteger *)len
|
||||||
{
|
{
|
||||||
[self subclassResponsibility: _cmd];
|
[self subclassResponsibility: _cmd];
|
||||||
|
@ -1226,6 +1236,17 @@ done:
|
||||||
return [[GSFileInputStream alloc] initWithFileAtPath: path];
|
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
|
- (NSInteger) read: (uint8_t *)buffer maxLength: (NSUInteger)len
|
||||||
{
|
{
|
||||||
[self subclassResponsibility: _cmd];
|
[self subclassResponsibility: _cmd];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue