@@ -34,10 +34,14 @@ typedef struct stat64 of_stat_t; #else typedef struct stat of_stat_t; #endif +#if defined(OF_MORPHOS) && !defined(OF_IXEMUL) +typedef long BPTR; +#endif + /*! * @class OFFile OFFile.h ObjFW/OFFile.h * * @brief A class which provides methods to read and write files. */ @@ -44,11 +48,11 @@ @interface OFFile: OFSeekableStream { #if !defined(OF_MORPHOS) || defined(OF_IXEMUL) int _fd; #else - long _fd; + BPTR _handle; bool _append; #endif bool _atEndOfStream; } @@ -75,18 +79,29 @@ * @return A new autoreleased OFFile */ + (instancetype)fileWithPath: (OFString *)path mode: (OFString *)mode; +#if !defined(OF_MORPHOS) || defined(OF_IXEMUL) /*! * @brief Creates a new OFFile with the specified file descriptor. * * @param fd A file descriptor, returned from for example open(). - * It is not closed when the OFFile object is deallocated! + * It is closed when the OFFile object is deallocated! * @return A new autoreleased OFFile */ + (instancetype)fileWithFileDescriptor: (int)fd; +#else +/*! + * @brief Creates a new OFFile with the specified handle. + * + * @param handle A handle, returned from for example Open(). + * It is closed when the OFFile object is deallocated! + * @return A new autoreleased OFFile + */ ++ (instancetype)fileWithHandle: (BPTR)handle; +#endif - init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated OFFile. @@ -111,17 +126,29 @@ * @return An initialized OFFile */ - initWithPath: (OFString *)path mode: (OFString *)mode; +#if !defined(OF_MORPHOS) || defined(OF_IXEMUL) /*! * @brief Initializes an already allocated OFFile. * * @param fd A file descriptor, returned from for example open(). - * It is not closed when the OFFile object is deallocated! + * It is closed when the OFFile object is deallocated! + * @return An initialized OFFile */ - initWithFileDescriptor: (int)fd; +#else +/*! + * @brief Initializes an already allocated OFFile. + * + * @param handle A handle, returned from for example Open(). + * It is closed when the OFFile object is deallocated! + * @return An initialized OFFile + */ +- initWithHandle: (BPTR)handle; +#endif @end #ifdef __cplusplus extern "C" { #endif