mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-29 16:01:38 +00:00
NSStream additions
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@22496 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
c91bf05a5e
commit
5f074036fb
10 changed files with 2503 additions and 1 deletions
|
@ -92,6 +92,7 @@ NSRunLoop.h \
|
|||
NSScanner.h \
|
||||
NSSerialization.h \
|
||||
NSSet.h \
|
||||
NSStream.h \
|
||||
NSString.h \
|
||||
NSTask.h \
|
||||
NSThread.h \
|
||||
|
|
|
@ -133,6 +133,7 @@ GSFormat.m \
|
|||
GSFTPURLHandle.m \
|
||||
GSHTTPURLHandle.m \
|
||||
GSSet.m \
|
||||
GSStream.m \
|
||||
GSString.m \
|
||||
GSValue.m \
|
||||
NSAttributedString.m \
|
||||
|
@ -321,6 +322,7 @@ NSScanner.h \
|
|||
NSSerialization.h \
|
||||
NSSet.h \
|
||||
NSSortDescriptor.h \
|
||||
NSStream.h \
|
||||
NSString.h \
|
||||
NSTask.h \
|
||||
NSThread.h \
|
||||
|
|
511
Source/GSStream.m
Normal file
511
Source/GSStream.m
Normal file
|
@ -0,0 +1,511 @@
|
|||
/** Implementation for GSStream for GNUStep
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Derek Zhou <derekzhou@gmail.com>
|
||||
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
||||
Date: 2006
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
|
||||
*/
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <Foundation/NSData.h>
|
||||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSRunLoop.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSError.h>
|
||||
#include <Foundation/NSValue.h>
|
||||
#include <Foundation/NSHost.h>
|
||||
|
||||
#include "GSStream.h"
|
||||
|
||||
NSString * const NSStreamDataWrittenToMemoryStreamKey
|
||||
= @"NSStreamDataWrittenToMemoryStreamKey";
|
||||
NSString * const NSStreamFileCurrentOffsetKey
|
||||
= @"NSStreamFileCurrentOffsetKey";
|
||||
|
||||
NSString * const NSStreamSocketSecurityLevelKey
|
||||
= @"NSStreamSocketSecurityLevelKey";
|
||||
NSString * const NSStreamSocketSecurityLevelNone
|
||||
= @"NSStreamSocketSecurityLevelNone";
|
||||
NSString * const NSStreamSocketSecurityLevelSSLv2
|
||||
= @"NSStreamSocketSecurityLevelSSLv2";
|
||||
NSString * const NSStreamSocketSecurityLevelSSLv3
|
||||
= @"NSStreamSocketSecurityLevelSSLv3";
|
||||
NSString * const NSStreamSocketSecurityLevelTLSv1
|
||||
= @"NSStreamSocketSecurityLevelTLSv1";
|
||||
NSString * const NSStreamSocketSecurityLevelNegotiatedSSL
|
||||
= @"NSStreamSocketSecurityLevelNegotiatedSSL";
|
||||
NSString * const NSStreamSocketSSLErrorDomain
|
||||
= @"NSStreamSocketSSLErrorDomain";
|
||||
NSString * const NSStreamSOCKSErrorDomain
|
||||
= @"NSStreamSOCKSErrorDomain";
|
||||
NSString * const NSStreamSOCKSProxyConfigurationKey
|
||||
= @"NSStreamSOCKSProxyConfigurationKey";
|
||||
NSString * const NSStreamSOCKSProxyHostKey
|
||||
= @"NSStreamSOCKSProxyHostKey";
|
||||
NSString * const NSStreamSOCKSProxyPasswordKey
|
||||
= @"NSStreamSOCKSProxyPasswordKey";
|
||||
NSString * const NSStreamSOCKSProxyPortKey
|
||||
= @"NSStreamSOCKSProxyPortKey";
|
||||
NSString * const NSStreamSOCKSProxyUserKey
|
||||
= @"NSStreamSOCKSProxyUserKey";
|
||||
NSString * const NSStreamSOCKSProxyVersion4
|
||||
= @"NSStreamSOCKSProxyVersion4";
|
||||
NSString * const NSStreamSOCKSProxyVersion5
|
||||
= @"NSStreamSOCKSProxyVersion5";
|
||||
NSString * const NSStreamSOCKSProxyVersionKey
|
||||
= @"NSStreamSOCKSProxyVersionKey";
|
||||
|
||||
|
||||
@implementation GSStream
|
||||
|
||||
- (void) close
|
||||
{
|
||||
NSAssert(_currentStatus != NSStreamStatusNotOpen
|
||||
&& _currentStatus != NSStreamStatusClosed,
|
||||
@"Attempt to close a stream not yet opened.");
|
||||
[self _setStatus: NSStreamStatusClosed];
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
DESTROY(_runloop);
|
||||
DESTROY(_modes);
|
||||
DESTROY(_properties);
|
||||
DESTROY(_lastError);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id) delegate
|
||||
{
|
||||
return _delegate;
|
||||
}
|
||||
|
||||
- (void) open
|
||||
{
|
||||
NSAssert(_currentStatus == NSStreamStatusNotOpen
|
||||
|| _currentStatus == NSStreamStatusOpening,
|
||||
@"Attempt to open a stream already opened.");
|
||||
[self _setStatus: NSStreamStatusOpen];
|
||||
}
|
||||
|
||||
- (void) setDelegate: (id)delegate
|
||||
{
|
||||
if (delegate)
|
||||
{
|
||||
_delegate = delegate;
|
||||
}
|
||||
else
|
||||
{
|
||||
_delegate = self;
|
||||
}
|
||||
_delegateValid
|
||||
= [_delegate respondsToSelector: @selector(stream:handleEvent:)];
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super init]) != nil)
|
||||
{
|
||||
_delegate = self;
|
||||
_properties = nil;
|
||||
_lastError = nil;
|
||||
_modes = [NSMutableArray new];
|
||||
_currentStatus = NSStreamStatusNotOpen;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL) setProperty: (id)property forKey: (NSString *)key
|
||||
{
|
||||
if (_properties == nil)
|
||||
{
|
||||
_properties = [NSMutableDictionary new];
|
||||
}
|
||||
[_properties setObject: property forKey: key];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (id) propertyForKey: (NSString *)key
|
||||
{
|
||||
return [_properties objectForKey: key];
|
||||
}
|
||||
|
||||
- (NSError *) streamError
|
||||
{
|
||||
if (_currentStatus == NSStreamStatusError)
|
||||
{
|
||||
return _lastError;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSStreamStatus) streamStatus
|
||||
{
|
||||
return _currentStatus;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation GSStream (Private)
|
||||
|
||||
- (BOOL) _isOpened
|
||||
{
|
||||
return !(_currentStatus == NSStreamStatusNotOpen
|
||||
|| _currentStatus == NSStreamStatusOpening
|
||||
|| _currentStatus == NSStreamStatusClosed);
|
||||
}
|
||||
|
||||
- (void) _recordError
|
||||
{
|
||||
// make an error
|
||||
NSError *theError = [NSError errorWithDomain: NSPOSIXErrorDomain
|
||||
code: errno
|
||||
userInfo: nil];
|
||||
perror("");
|
||||
ASSIGN(_lastError, theError);
|
||||
_currentStatus = NSStreamStatusError;
|
||||
}
|
||||
|
||||
- (void) _sendEvent: (NSStreamEvent)event
|
||||
{
|
||||
if (_delegateValid)
|
||||
{
|
||||
[(id <GSStreamListener>)_delegate stream: self handleEvent: event];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) _setStatus: (NSStreamStatus)newStatus
|
||||
{
|
||||
// last error before closing is preserved
|
||||
if (_currentStatus != NSStreamStatusError
|
||||
|| newStatus != NSStreamStatusClosed)
|
||||
{
|
||||
_currentStatus = newStatus;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation GSInputStream
|
||||
+ (void) initialize
|
||||
{
|
||||
if (self == [GSInputStream class])
|
||||
{
|
||||
GSObjCAddClassBehavior(self, [GSStream class]);
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation GSOutputStream
|
||||
+ (void) initialize
|
||||
{
|
||||
if (self == [GSOutputStream class])
|
||||
{
|
||||
GSObjCAddClassBehavior(self, [GSStream class]);
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@implementation GSMemoryInputStream
|
||||
|
||||
/**
|
||||
* the designated initializer
|
||||
*/
|
||||
- (id) initWithData: (NSData *)data
|
||||
{
|
||||
if ((self = [super init]) != nil)
|
||||
{
|
||||
ASSIGN(_data, data);
|
||||
_pointer = 0;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
if ([self _isOpened])
|
||||
[self close];
|
||||
RELEASE(_data);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (int) read: (uint8_t *)buffer maxLength: (unsigned int)len
|
||||
{
|
||||
unsigned long dataSize = [_data length];
|
||||
unsigned long copySize;
|
||||
|
||||
NSAssert(dataSize >= _pointer, @"Buffer overflow!");
|
||||
if (len + _pointer > dataSize)
|
||||
{
|
||||
copySize = dataSize - _pointer;
|
||||
}
|
||||
else
|
||||
{
|
||||
copySize = len;
|
||||
}
|
||||
if (copySize)
|
||||
{
|
||||
memcpy(buffer, [_data bytes] + _pointer, copySize);
|
||||
_pointer = _pointer + copySize;
|
||||
}
|
||||
else
|
||||
{
|
||||
[self _setStatus: NSStreamStatusAtEnd];
|
||||
}
|
||||
return copySize;
|
||||
}
|
||||
|
||||
- (BOOL) getBuffer: (uint8_t **)buffer length: (unsigned int *)len
|
||||
{
|
||||
unsigned long dataSize = [_data length];
|
||||
|
||||
NSAssert(dataSize >= _pointer, @"Buffer overflow!");
|
||||
*buffer = (uint8_t*)[_data bytes] + _pointer;
|
||||
*len = dataSize - _pointer;
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL) hasBytesAvailable
|
||||
{
|
||||
unsigned long dataSize = [_data length];
|
||||
|
||||
return (dataSize > _pointer);
|
||||
}
|
||||
|
||||
- (void) scheduleInRunLoop: (NSRunLoop *)aRunLoop forMode: (NSString *)mode
|
||||
{
|
||||
NSAssert(!_runloop || _runloop == aRunLoop,
|
||||
@"Attempt to schedule in more than one runloop.");
|
||||
ASSIGN(_runloop, aRunLoop);
|
||||
if (![_modes containsObject: mode])
|
||||
[_modes addObject: mode];
|
||||
if ([self _isOpened])
|
||||
[_runloop performSelector:@selector(dispatch:) target: self
|
||||
argument: nil order: 0 modes: _modes];
|
||||
}
|
||||
|
||||
- (void) removeFromRunLoop: (NSRunLoop *)aRunLoop forMode: (NSString *)mode
|
||||
{
|
||||
NSAssert(_runloop == aRunLoop,
|
||||
@"Attempt to remove unscheduled runloop");
|
||||
if ([_modes containsObject: mode])
|
||||
{
|
||||
[_modes removeObject: mode];
|
||||
if ([self _isOpened])
|
||||
[_runloop cancelPerformSelector:@selector(dispatch:)
|
||||
target: self argument: nil];
|
||||
if ([_modes count] == 0)
|
||||
DESTROY(_runloop);
|
||||
}
|
||||
}
|
||||
|
||||
- (id) propertyForKey: (NSString *)key
|
||||
{
|
||||
if ([key isEqualToString: NSStreamFileCurrentOffsetKey])
|
||||
return [NSNumber numberWithLong: _pointer];
|
||||
return [super propertyForKey: key];
|
||||
}
|
||||
|
||||
- (void) open
|
||||
{
|
||||
[super open];
|
||||
if (_runloop)
|
||||
[_runloop performSelector: @selector(dispatch:)
|
||||
target: self
|
||||
argument: nil
|
||||
order: 0
|
||||
modes: _modes];
|
||||
}
|
||||
|
||||
- (void) close
|
||||
{
|
||||
if (_runloop)
|
||||
[_runloop cancelPerformSelectorsWithTarget: self];
|
||||
[super close];
|
||||
}
|
||||
|
||||
- (void) dispatch
|
||||
{
|
||||
BOOL av = [self hasBytesAvailable];
|
||||
NSStreamEvent myEvent = av ? NSStreamEventHasBytesAvailable :
|
||||
NSStreamEventEndEncountered;
|
||||
NSStreamStatus myStatus = av ? NSStreamStatusReading :
|
||||
NSStreamStatusAtEnd;
|
||||
|
||||
[self _setStatus: myStatus];
|
||||
[self _sendEvent: myEvent];
|
||||
// dispatch again iff still opened, and last event is not eos
|
||||
if (av && [self _isOpened])
|
||||
{
|
||||
[_runloop performSelector: @selector(dispatch:)
|
||||
target: self
|
||||
argument: nil
|
||||
order: 0
|
||||
modes: _modes];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation GSMemoryOutputStream
|
||||
|
||||
- (id) initToBuffer: (uint8_t *)buffer capacity: (unsigned int)capacity
|
||||
{
|
||||
if ((self = [super init]) != nil)
|
||||
{
|
||||
if (!buffer)
|
||||
{
|
||||
_data = [NSMutableData new];
|
||||
_fixedSize = NO;
|
||||
}
|
||||
else
|
||||
{
|
||||
_data = [[NSMutableData alloc] initWithBytesNoCopy: buffer
|
||||
length: capacity freeWhenDone: NO];
|
||||
_fixedSize = YES;
|
||||
}
|
||||
_pointer = 0;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_data);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (int) write: (const uint8_t *)buffer maxLength: (unsigned int)len
|
||||
{
|
||||
if (_fixedSize)
|
||||
{
|
||||
unsigned long dataLen = [_data length];
|
||||
uint8_t *origin = (uint8_t *)[_data mutableBytes];
|
||||
|
||||
if (_pointer+len>dataLen)
|
||||
len = dataLen - _pointer;
|
||||
memcpy(origin+_pointer, buffer, len);
|
||||
_pointer = _pointer + len;
|
||||
}
|
||||
else
|
||||
[_data appendBytes: buffer length: len];
|
||||
return len;
|
||||
}
|
||||
|
||||
- (BOOL) hasSpaceAvailable
|
||||
{
|
||||
if (_fixedSize)
|
||||
return [_data length]>_pointer;
|
||||
else
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void) scheduleInRunLoop: (NSRunLoop *)aRunLoop forMode: (NSString *)mode
|
||||
{
|
||||
NSAssert(!_runloop || _runloop == aRunLoop,
|
||||
@"Attempt to schedule in more than one runloop.");
|
||||
ASSIGN(_runloop, aRunLoop);
|
||||
if (![_modes containsObject: mode])
|
||||
[_modes addObject: mode];
|
||||
if ([self _isOpened])
|
||||
[_runloop performSelector: @selector(dispatch:)
|
||||
target: self
|
||||
argument: nil
|
||||
order: 0
|
||||
modes: _modes];
|
||||
}
|
||||
|
||||
- (void) removeFromRunLoop: (NSRunLoop *)aRunLoop forMode: (NSString *)mode
|
||||
{
|
||||
NSAssert(_runloop == aRunLoop,
|
||||
@"Attempt to remove unscheduled runloop");
|
||||
if ([_modes containsObject: mode])
|
||||
{
|
||||
[_modes removeObject: mode];
|
||||
if ([self _isOpened])
|
||||
[_runloop cancelPerformSelector: @selector(dispatch:)
|
||||
target: self
|
||||
argument: nil];
|
||||
if ([_modes count] == 0)
|
||||
DESTROY(_runloop);
|
||||
}
|
||||
}
|
||||
|
||||
- (id) propertyForKey: (NSString *)key
|
||||
{
|
||||
if ([key isEqualToString: NSStreamFileCurrentOffsetKey])
|
||||
{
|
||||
if (_fixedSize)
|
||||
return [NSNumber numberWithLong: _pointer];
|
||||
else
|
||||
return [NSNumber numberWithLong:[_data length]];
|
||||
}
|
||||
else if ([key isEqualToString: NSStreamDataWrittenToMemoryStreamKey])
|
||||
return _data;
|
||||
return [super propertyForKey: key];
|
||||
}
|
||||
|
||||
- (void) open
|
||||
{
|
||||
[super open];
|
||||
if (_runloop)
|
||||
{
|
||||
[_runloop performSelector: @selector(dispatch:)
|
||||
target: self
|
||||
argument: nil
|
||||
order: 0
|
||||
modes: _modes];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) close
|
||||
{
|
||||
if (_runloop)
|
||||
[_runloop cancelPerformSelectorsWithTarget: self];
|
||||
[super close];
|
||||
}
|
||||
|
||||
- (void) dispatch
|
||||
{
|
||||
BOOL av = [self hasSpaceAvailable];
|
||||
NSStreamEvent myEvent = av ? NSStreamEventHasSpaceAvailable :
|
||||
NSStreamEventEndEncountered;
|
||||
|
||||
[self _sendEvent: myEvent];
|
||||
// dispatch again iff still opened, and last event is not eos
|
||||
if (av && [self _isOpened])
|
||||
[_runloop performSelector: @selector(dispatch:)
|
||||
target: self
|
||||
argument: nil
|
||||
order: 0
|
||||
modes: _modes];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -31,7 +31,8 @@ SUBPROJECT_NAME = unix
|
|||
|
||||
unix_OBJC_FILES = \
|
||||
GSRunLoopCtxt.m \
|
||||
GSRunLoopWatcher.m
|
||||
GSRunLoopWatcher.m \
|
||||
NSStream.m
|
||||
|
||||
-include Makefile.preamble
|
||||
|
||||
|
|
1505
Source/unix/NSStream.m
Normal file
1505
Source/unix/NSStream.m
Normal file
File diff suppressed because it is too large
Load diff
|
@ -36,6 +36,7 @@ win32_OBJC_FILES =\
|
|||
NSMessagePortWin32.m \
|
||||
NSMessagePortNameServerWin32.m \
|
||||
NSRunLoopWin32.m \
|
||||
NSStreamWin32.m \
|
||||
NSUserDefaultsWin32.m \
|
||||
|
||||
|
||||
|
|
199
Source/win32/NSStreamWin32.m
Normal file
199
Source/win32/NSStreamWin32.m
Normal file
|
@ -0,0 +1,199 @@
|
|||
/** Implementation for NSStream for GNUStep
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Derek Zhou <derekzhou@gmail.com>
|
||||
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
||||
Date: 2006
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
|
||||
*/
|
||||
|
||||
#include <Foundation/NSData.h>
|
||||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSRunLoop.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSError.h>
|
||||
#include <Foundation/NSValue.h>
|
||||
#include <Foundation/NSHost.h>
|
||||
|
||||
#include "../GSStream.h"
|
||||
|
||||
@implementation NSStream
|
||||
|
||||
+ (void) getStreamsToHost: (NSHost *)host
|
||||
port: (int)port
|
||||
inputStream: (NSInputStream **)inputStream
|
||||
outputStream: (NSOutputStream **)outputStream
|
||||
{
|
||||
[self notImplemented:_cmd]
|
||||
}
|
||||
|
||||
- (void) close
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (void) open
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (void) setDelegate: (id)delegate
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (id) delegate
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (BOOL) setProperty: (id)property forKey: (NSString *)key
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (id) propertyForKey: (NSString *)key
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void) scheduleInRunLoop: (NSRunLoop *)aRunLoop forMode: (NSString *)mode
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (void) removeFromRunLoop: (NSRunLoop *)aRunLoop forMode: (NSString *)mode;
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (NSError *) streamError
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSStreamStatus) streamStatus
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return 0;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSInputStream
|
||||
|
||||
+ (id) inputStreamWithData: (NSData *)data
|
||||
{
|
||||
[self notImplemented:_cmd]
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (id) inputStreamWithFileAtPath: (NSString *)path
|
||||
{
|
||||
[self notImplemented:_cmd]
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (id) initWithData: (NSData *)data
|
||||
{
|
||||
[self notImplemented:_cmd];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (id) initWithFileAtPath: (NSString *)path
|
||||
{
|
||||
[self notImplemented:_cmd];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (int) read: (uint8_t *)buffer maxLength: (unsigned int)len
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return -1;
|
||||
}
|
||||
|
||||
- (BOOL) getBuffer: (uint8_t **)buffer length: (unsigned int *)len
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL) hasBytesAvailable
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return NO;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSOutputStream
|
||||
|
||||
+ (id) outputStreamToMemory
|
||||
{
|
||||
[self notImplemented:_cmd];
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (id) outputStreamToBuffer: (uint8_t *)buffer capacity: (unsigned int)capacity
|
||||
{
|
||||
[self notImplemented:_cmd];
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (id) outputStreamToFileAtPath: (NSString *)path append: (BOOL)shouldAppend
|
||||
{
|
||||
[self notImplemented:_cmd];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (id) initToMemory
|
||||
{
|
||||
[self notImplemented:_cmd];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (id) initToBuffer: (uint8_t *)buffer capacity: (unsigned int)capacity
|
||||
{
|
||||
[self notImplemented:_cmd];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (id) initToFileAtPath: (NSString *)path append: (BOOL)shouldAppend
|
||||
{
|
||||
[self notImplemented:_cmd];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (int) write: (const uint8_t *)buffer maxLength: (unsigned int)len
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return -1;
|
||||
}
|
||||
|
||||
- (BOOL) hasSpaceAvailable
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return NO;
|
||||
}
|
||||
|
||||
@end
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue