Differences From Artifact [1933c9d596]:
- File
src/OFFile.m
— part of check-in
[a0fd103a0b]
at
2021-03-07 02:36:04
on branch trunk
— Style change: Allow more than 1 argument per line
This is only migrating some places, others will be migrated as they are
touched. (user: js, size: 11690) [annotate] [blame] [check-ins using] [more...]
To Artifact [9e3c48245d]:
- File src/OFFile.m — part of check-in [94ebfb3671] at 2021-04-17 14:36:08 on branch new-naming-convention — of_file_handle_t -> OFFileHandle (user: js, size: 11665) [annotate] [blame] [check-ins using]
| ︙ | ︙ | |||
75 76 77 78 79 80 81 | #ifndef O_EXLOCK # define O_EXLOCK 0 #endif #ifndef OF_AMIGAOS # define closeHandle(h) close(h) #else | | | | | | 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
#ifndef O_EXLOCK
# define O_EXLOCK 0
#endif
#ifndef OF_AMIGAOS
# define closeHandle(h) close(h)
#else
static struct OFFileHandle
OFFileHandle previous, next;
BPTR handle;
bool append;
} *firstHandle = NULL;
static void
closeHandle(OFFileHandle handle)
{
Close(handle->handle);
if (handle->previous != NULL)
handle->previous->next = handle->next;
if (handle->next != NULL)
handle->next->previous = handle->previous;
if (firstHandle == handle)
firstHandle = handle->next;
free(handle);
}
OF_DESTRUCTOR()
{
for (OFFileHandle iter = firstHandle; iter != NULL;
iter = iter->next)
Close(iter->handle);
}
#endif
#ifndef OF_AMIGAOS
static int
|
| ︙ | ︙ | |||
188 189 190 191 192 193 194 |
}
+ (instancetype)fileWithURL: (OFURL *)URL mode: (OFString *)mode
{
return [[[self alloc] initWithURL: URL mode: mode] autorelease];
}
| | | | 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
}
+ (instancetype)fileWithURL: (OFURL *)URL mode: (OFString *)mode
{
return [[[self alloc] initWithURL: URL mode: mode] autorelease];
}
+ (instancetype)fileWithHandle: (OFFileHandle)handle
{
return [[[self alloc] initWithHandle: handle] autorelease];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithPath: (OFString *)path mode: (OFString *)mode
{
OFFileHandle handle;
@try {
void *pool = objc_autoreleasePoolPush();
int flags;
#ifndef OF_AMIGAOS
if ((flags = parseMode(mode.UTF8String)) == -1)
|
| ︙ | ︙ | |||
336 337 338 339 340 341 342 | self = [self initWithPath: fileSystemRepresentation mode: mode]; objc_autoreleasePoolPop(pool); return self; } | | | 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 |
self = [self initWithPath: fileSystemRepresentation mode: mode];
objc_autoreleasePoolPop(pool);
return self;
}
- (instancetype)initWithHandle: (OFFileHandle)handle
{
self = [super init];
_handle = handle;
return self;
}
|
| ︙ | ︙ | |||
447 448 449 450 451 452 453 | bytesWritten: 0 errNo: errno]; #endif return (size_t)bytesWritten; } | | | | 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 |
bytesWritten: 0
errNo: errno];
#endif
return (size_t)bytesWritten;
}
- (OFFileOffset)lowlevelSeekToOffset: (OFFileOffset)offset whence: (int)whence
{
OFFileOffset ret;
if (_handle == OF_INVALID_FILE_HANDLE)
@throw [OFNotOpenException exceptionWithObject: self];
#ifndef OF_AMIGAOS
# if defined(OF_WINDOWS)
ret = _lseeki64(_handle, offset, whence);
|
| ︙ | ︙ |