Skip to content

Commit

Permalink
Add getOffset:error: implementation to base
Browse files Browse the repository at this point in the history
  • Loading branch information
gcasa committed Sep 13, 2024
1 parent cdbb1cc commit 9c5107e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Headers/Foundation/NSFileHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ GS_EXPORT_CLASS
- (NSData*) readDataToEndOfFile;
- (NSData*) readDataOfLength: (unsigned int)len;
- (void) writeData: (NSData*)item;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_15, GS_API_LATEST)
- (BOOL) getOffset: (unsigned long long *)offsetInFile error: (NSError **)error;
#endif

// Asynchronous I/O operations

Expand Down
1 change: 0 additions & 1 deletion Source/GSFileHandle.m
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,6 @@ - (void) writeData: (NSData*)item
}
}


// Asynchronous I/O operations

- (void) acceptConnectionInBackgroundAndNotifyForModes: (NSArray*)modes
Expand Down
19 changes: 19 additions & 0 deletions Source/NSFileHandle.m
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,25 @@ - (void) writeData: (NSData*)item
[self subclassResponsibility: _cmd];
}

/**
* Get the current position in the file.
*/
- (BOOL) getOffset: (unsigned long long *)offsetInFile error: (NSError **)error
{
BOOL result = YES;

// We can do the concrete implementation here since the method relies on
// offsetInFile to get the offset.
*error = nil;
*offsetInFile = [self offsetInFile];
if (*offsetInFile == -1)
{
*offsetInFile = 0;
result = NO;
}

return result;
}

// Asynchronous I/O operations

Expand Down

0 comments on commit 9c5107e

Please sign in to comment.