Overview
Comment: | Add -[initWithFilePointer:] to OFFile. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
3cf27e00c4d48bcebbc2dd27b44ce231 |
User & Date: | js on 2009-09-27 14:23:29 |
Other Links: | manifest | tags |
Context
2009-09-27
| ||
15:04 | Small documentation addendum. check-in: ada9f37216 user: js tags: trunk | |
14:23 | Add -[initWithFilePointer:] to OFFile. check-in: 3cf27e00c4 user: js tags: trunk | |
11:42 | Migration of OFArray tests to new testing framework. check-in: dbb0223586 user: js tags: trunk | |
Changes
Modified src/OFFile.h from [9b05f93324] to [c01ec34601].
︙ | ︙ | |||
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | /** * The OFFile class provides functions to read, write and manipulate files. */ @interface OFFile: OFStream { FILE *fp; } /** * \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 * \return A new autoreleased OFFile */ + fileWithPath: (OFString*)path mode: (OFString*)mode; /** * \return An OFFile singleton for stdin */ + standardInput; /** * \return An OFFile singleton for stdout | > > > > > > > > | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | /** * 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 * \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; /** * \return An OFFile singleton for stdout |
︙ | ︙ | |||
118 119 120 121 122 123 124 125 126 127 128 129 130 131 | * \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 * \return An initialized OFFile */ - initWithPath: (OFString*)path mode: (OFString*)mode; /** * 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. * The buffer MUST be at least size * nitems big! * \param nitems nitem The number of items to read | > > > > > > > > | 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | * \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 * \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. * The buffer MUST be at least size * nitems big! * \param nitems nitem The number of items to read |
︙ | ︙ | |||
146 147 148 149 150 151 152 | */ - (size_t)writeNItems: (size_t)nitems ofSize: (size_t)size fromBuffer: (const char*)buf; @end @interface OFFileSingleton: OFFile | < | 162 163 164 165 166 167 168 169 | */ - (size_t)writeNItems: (size_t)nitems ofSize: (size_t)size fromBuffer: (const char*)buf; @end @interface OFFileSingleton: OFFile @end |
Modified src/OFFile.m from [dcca7be75f] to [eabe2a45bb].
︙ | ︙ | |||
30 31 32 33 34 35 36 37 38 39 40 41 42 43 | @implementation OFFile + fileWithPath: (OFString*)path mode: (OFString*)mode { return [[[self alloc] initWithPath: path mode: mode] autorelease]; } + standardInput { if (of_file_stdin == nil) of_file_stdin = [[OFFileSingleton alloc] initWithFilePointer: stdin]; | > > > > > | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | @implementation OFFile + fileWithPath: (OFString*)path mode: (OFString*)mode { return [[[self alloc] initWithPath: path mode: mode] autorelease]; } + fileWithFilePointer: (FILE*)fp_ { return [[[self alloc] initWithFilePointer: fp_] autorelease]; } + standardInput { if (of_file_stdin == nil) of_file_stdin = [[OFFileSingleton alloc] initWithFilePointer: stdin]; |
︙ | ︙ | |||
137 138 139 140 141 142 143 144 145 146 147 148 149 | if ((fp = fopen([path cString], [mode cString])) == NULL) { c = isa; [super dealloc]; @throw [OFOpenFileFailedException newWithClass: c path: path mode: mode]; } return self; } - (void)dealloc { | > > > > > > > > > > > | | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | if ((fp = fopen([path cString], [mode cString])) == NULL) { c = isa; [super dealloc]; @throw [OFOpenFileFailedException newWithClass: c path: path mode: mode]; } close = YES; return self; } - initWithFilePointer: (FILE*)fp_ { self = [super init]; fp = fp_; return self; } - (void)dealloc { if (close == YES && fp != NULL) fclose(fp); [super dealloc]; } - (BOOL)atEndOfStream { |
︙ | ︙ | |||
222 223 224 225 226 227 228 | fp = NULL; return self; } @end @implementation OFFileSingleton | < < < < < < < < < | 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | fp = NULL; return self; } @end @implementation OFFileSingleton - initWithPath: (OFString*)path mode: (OFString*)mode { @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; } |
︙ | ︙ |