@@ -25,10 +25,11 @@ * The OFFile class provides functions to read, write and manipulate files. */ @interface OFFile: OFStream { FILE *fp; + BOOL close; } /** * \param path The path to the file to open as a string * \param mode The mode in which the file should be opened as a string @@ -35,10 +36,17 @@ * \return A new autoreleased OFFile */ + fileWithPath: (OFString*)path mode: (OFString*)mode; +/** + * \param fp A file pointer, returned from for example fopen(). + * It is not closed when the OFFile object is deallocated! + * \return A new autoreleased OFFile + */ ++ fileWithFilePointer: (FILE*)fp; + /** * \return An OFFile singleton for stdin */ + standardInput; @@ -120,10 +128,18 @@ * \return An initialized OFFile */ - initWithPath: (OFString*)path mode: (OFString*)mode; +/** + * Initializes an already allocated OFFile. + * + * \param fp A file pointer, returned from for example fopen(). + * It is not closed when the OFFile object is deallocated! + */ +- initWithFilePointer: (FILE*)fp; + /** * Reads from the file into a buffer. * * \param buf The buffer into which the data is read * \param size The size of the data that should be read. @@ -148,7 +164,6 @@ ofSize: (size_t)size fromBuffer: (const char*)buf; @end @interface OFFileSingleton: OFFile -- initWithFilePointer: (FILE*)fp; @end