@@ -77,18 +77,18 @@ #endif #ifndef OF_AMIGAOS # define closeHandle(h) close(h) #else -static struct of_file_handle { - of_file_handle_t previous, next; +static struct _OFFileHandle + struct _OFFileHandle *previous, *next; BPTR handle; bool append; } *firstHandle = NULL; static void -closeHandle(of_file_handle_t handle) +closeHandle(OFFileHandle handle) { Close(handle->handle); if (handle->previous != NULL) handle->previous->next = handle->next; @@ -96,16 +96,16 @@ handle->next->previous = handle->previous; if (firstHandle == handle) firstHandle = handle->next; - free(handle); + OFFreeMemory(handle); } OF_DESTRUCTOR() { - for (of_file_handle_t iter = firstHandle; iter != NULL; + for (OFFileHandle iter = firstHandle; iter != NULL; iter = iter->next) Close(iter->handle); } #endif @@ -190,11 +190,11 @@ + (instancetype)fileWithURL: (OFURL *)URL mode: (OFString *)mode { return [[[self alloc] initWithURL: URL mode: mode] autorelease]; } -+ (instancetype)fileWithHandle: (of_file_handle_t)handle ++ (instancetype)fileWithHandle: (OFFileHandle)handle { return [[[self alloc] initWithHandle: handle] autorelease]; } - (instancetype)init @@ -202,11 +202,11 @@ OF_INVALID_INIT_METHOD } - (instancetype)initWithPath: (OFString *)path mode: (OFString *)mode { - of_file_handle_t handle; + OFFileHandle handle; @try { void *pool = objc_autoreleasePoolPush(); int flags; @@ -236,11 +236,11 @@ @throw [OFOpenItemFailedException exceptionWithPath: path mode: mode errNo: errno]; #else - handle = of_alloc(1, sizeof(*handle)); + handle = OFAllocMemory(1, sizeof(*handle)); @try { if ((flags = parseMode(mode.UTF8String, &handle->append)) == -1) @throw [OFInvalidArgumentException exception]; @@ -298,11 +298,11 @@ if (firstHandle != NULL) firstHandle->previous = handle; firstHandle = handle; } @catch (id e) { - free(handle); + OFFreeMemory(handle); @throw e; } #endif objc_autoreleasePoolPop(pool); @@ -338,11 +338,11 @@ objc_autoreleasePoolPop(pool); return self; } -- (instancetype)initWithHandle: (of_file_handle_t)handle +- (instancetype)initWithHandle: (OFFileHandle)handle { self = [super init]; _handle = handle; @@ -349,21 +349,21 @@ return self; } - (bool)lowlevelIsAtEndOfStream { - if (_handle == OF_INVALID_FILE_HANDLE) + if (_handle == OFInvalidFileHandle) @throw [OFNotOpenException exceptionWithObject: self]; return _atEndOfStream; } - (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { ssize_t ret; - if (_handle == OF_INVALID_FILE_HANDLE) + if (_handle == OFInvalidFileHandle) @throw [OFNotOpenException exceptionWithObject: self]; #if defined(OF_WINDOWS) if (length > UINT_MAX) @throw [OFOutOfRangeException exception]; @@ -393,11 +393,11 @@ return ret; } - (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { - if (_handle == OF_INVALID_FILE_HANDLE) + if (_handle == OFInvalidFileHandle) @throw [OFNotOpenException exceptionWithObject: self]; #if defined(OF_WINDOWS) int bytesWritten; @@ -449,15 +449,15 @@ #endif return (size_t)bytesWritten; } -- (of_offset_t)lowlevelSeekToOffset: (of_offset_t)offset whence: (int)whence +- (OFFileOffset)lowlevelSeekToOffset: (OFFileOffset)offset whence: (int)whence { - of_offset_t ret; + OFFileOffset ret; - if (_handle == OF_INVALID_FILE_HANDLE) + if (_handle == OFInvalidFileHandle) @throw [OFNotOpenException exceptionWithObject: self]; #ifndef OF_AMIGAOS # if defined(OF_WINDOWS) ret = _lseeki64(_handle, offset, whence); @@ -523,22 +523,22 @@ } #endif - (void)close { - if (_handle == OF_INVALID_FILE_HANDLE) + if (_handle == OFInvalidFileHandle) @throw [OFNotOpenException exceptionWithObject: self]; closeHandle(_handle); - _handle = OF_INVALID_FILE_HANDLE; + _handle = OFInvalidFileHandle; [super close]; } - (void)dealloc { - if (_handle != OF_INVALID_FILE_HANDLE) + if (_handle != OFInvalidFileHandle) [self close]; [super dealloc]; } @end