@@ -16,15 +16,15 @@ #import "OFSeekableStream.h" #import "OFKernelEventObserver.h" #ifndef OF_AMIGAOS # define OF_FILE_HANDLE_IS_FD -# define OF_INVALID_FILE_HANDLE (-1) -typedef int of_file_handle_t; +typedef int OFFileHandle; +static const OFFileHandle OFInvalidFileHandle = -1; #else -# define OF_INVALID_FILE_HANDLE NULL -typedef struct of_file_handle *of_file_handle_t; +typedef struct _OFFileHandle *OFFileHandle; +static const OFFileHandle OFInvalidFileHandle = NULL; #endif OF_ASSUME_NONNULL_BEGIN @class OFURL; @@ -38,11 +38,11 @@ @interface OFFile: OFSeekableStream #ifdef OF_FILE_HANDLE_IS_FD #endif { - of_file_handle_t _handle; + OFFileHandle _handle; bool _atEndOfStream; } /** * @brief Creates a new OFFile with the specified path and mode. @@ -61,12 +61,11 @@ * `w+x` | Read-write, create or fail, exclusive * `a` | Write-only, create or append * `a+` | Read-write, create or append * @return A new autoreleased OFFile */ -+ (instancetype)fileWithPath: (OFString *)path - mode: (OFString *)mode; ++ (instancetype)fileWithPath: (OFString *)path mode: (OFString *)mode; /** * @brief Creates a new OFFile with the specified URL and mode. * * @param URL The URL to the file to open @@ -82,22 +81,21 @@ * `w+x` | Read-write, create or fail, exclusive * `a` | Write-only, create or append * `a+` | Read-write, create or append * @return A new autoreleased OFFile */ -+ (instancetype)fileWithURL: (OFURL *)URL - mode: (OFString *)mode; ++ (instancetype)fileWithURL: (OFURL *)URL mode: (OFString *)mode; /** * @brief Creates a new OFFile with the specified native file handle. * * @param handle A native file handle. If OF_FILE_HANDLE_IS_FD is defined, this * is a file descriptor. The handle is closed when the OFFile * object is deallocated! * @return A new autoreleased OFFile */ -+ (instancetype)fileWithHandle: (of_file_handle_t)handle; ++ (instancetype)fileWithHandle: (OFFileHandle)handle; - (instancetype)init OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFFile. @@ -119,12 +117,11 @@ * `ab` | write-only, create, append, binary * `a+` | read-write, create, append * `ab+` or `a+b` | read-write, create, append, binary * @return An initialized OFFile */ -- (instancetype)initWithPath: (OFString *)path - mode: (OFString *)mode; +- (instancetype)initWithPath: (OFString *)path mode: (OFString *)mode; /** * @brief Initializes an already allocated OFFile. * * @param URL The URL to the file to open @@ -144,21 +141,19 @@ * `ab` | write-only, create, append, binary * `a+` | read-write, create, append * `ab+` or `a+b` | read-write, create, append, binary * @return An initialized OFFile */ -- (instancetype)initWithURL: (OFURL *)URL - mode: (OFString *)mode; +- (instancetype)initWithURL: (OFURL *)URL mode: (OFString *)mode; /** * @brief Initializes an already allocated OFFile. * * @param handle A native file handle. If OF_FILE_HANDLE_IS_FD is defined, this * is a file descriptor. The handle is closed when the OFFile * object is deallocated! * @return An initialized OFFile */ -- (instancetype)initWithHandle: (of_file_handle_t)handle - OF_DESIGNATED_INITIALIZER; +- (instancetype)initWithHandle: (OFFileHandle)handle OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END