Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

-writeData:error: variant

  • Loading branch information...
commit 90d5d878286eea2abf88f0a93275d94f60500cc6 1 parent 9e0cb3d
@mikeabdullah mikeabdullah authored
Showing with 14 additions and 7 deletions.
  1. +1 −0  CK2SFTPFileHandle.h
  2. +13 −7 CK2SFTPFileHandle.m
View
1  CK2SFTPFileHandle.h
@@ -27,6 +27,7 @@
- (BOOL)closeFile:(NSError **)error;
+- (BOOL)writeData:(NSData *)data error:(NSError **)error;
- (NSInteger)write:(const uint8_t *)buffer maxLength:(NSUInteger)length error:(NSError **)error;
- (NSInteger)write:(const uint8_t *)buffer maxLength:(NSUInteger)length;
View
20 CK2SFTPFileHandle.m
@@ -60,6 +60,15 @@ - (void)dealloc;
- (void)writeData:(NSData *)data;
{
+ NSError *error;
+ if (![self writeData:data error:&error])
+ {
+ [NSException raise:NSFileHandleOperationException format:@"%@", [error localizedDescription]];
+ }
+}
+
+- (BOOL)writeData:(NSData *)data error:(NSError **)error;
+{
NSUInteger offset = 0;
NSUInteger remainder = [data length];
@@ -67,17 +76,14 @@ - (void)writeData:(NSData *)data;
{
const void *bytes = [data bytes];
- NSError *error;
- NSInteger written = [self write:bytes+offset maxLength:remainder error:&error];
-
- if (written < 0)
- {
- [NSException raise:NSFileHandleOperationException format:@"%@", [error localizedDescription]];
- }
+ NSInteger written = [self write:bytes+offset maxLength:remainder error:error];
+ if (written < 0) return NO;
offset+=written;
remainder-=written;
}
+
+ return YES;
}
- (NSInteger)write:(const uint8_t *)buffer maxLength:(NSUInteger)length error:(NSError **)error;
Please sign in to comment.
Something went wrong with that request. Please try again.