mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
issue 325
This commit is contained in:
parent
99fe8d65e8
commit
4961287024
4 changed files with 33 additions and 1 deletions
|
@ -1,3 +1,10 @@
|
|||
2024-11-08 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Headers/Foundation/NSFileHandle.h:
|
||||
* Source/GSFileHandle.m:
|
||||
* Source/NSFileHandle.m:
|
||||
Add -truncateAtOffset:error: method (issue 325)
|
||||
|
||||
2024-11-03 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSFileManager.m: Fix case where positive result of asking
|
||||
|
|
|
@ -99,6 +99,11 @@ GS_EXPORT_CLASS
|
|||
- (void) synchronizeFile;
|
||||
- (void) truncateFileAtOffset: (unsigned long long)pos;
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_15, GS_API_LATEST)
|
||||
- (BOOL) truncateAtOffset: (unsigned long long)offset
|
||||
error: (out NSError **)error;
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
// Notification names.
|
||||
|
|
|
@ -1722,7 +1722,6 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
{
|
||||
[NSException raise: NSFileHandleOperationException
|
||||
format: @"attempt to truncate invalid file"];
|
||||
|
||||
}
|
||||
if (ftruncate(descriptor, pos) < 0)
|
||||
{
|
||||
|
@ -1732,6 +1731,21 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
|||
[self seekToFileOffset: pos];
|
||||
}
|
||||
|
||||
- (BOOL) truncateAtOffset: (unsigned long long)offset
|
||||
error: (out NSError **)error
|
||||
{
|
||||
if (ftruncate((isStandardFile ? descriptor : -1), offset) < 0)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
*error = [NSError _last];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
[self seekToFileOffset: offset];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void) writeInBackgroundAndNotify: (NSData*)item forModes: (NSArray*)modes
|
||||
{
|
||||
NSMutableDictionary* info;
|
||||
|
|
|
@ -467,6 +467,12 @@ static Class NSFileHandle_ssl_class = nil;
|
|||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (BOOL) truncateAtOffset: (unsigned long long)offset
|
||||
error: (out NSError **)error
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return NO;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
Loading…
Reference in a new issue