Changes in / [06c61e2:9a3a313]
- Location:
- libcfa/src
- Files:
-
- 2 edited
-
fstream.cfa (modified) (7 diffs)
-
fstream.hfa (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/fstream.cfa
r06c61e2 r9a3a313 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 2 9 22:34:10202113 // Update Count : 4 5412 // Last Modified On : Thu Jul 22 11:34:41 2021 13 // Update Count : 448 14 14 // 15 15 … … 142 142 143 143 if ( fclose( (FILE *)(os.file$) ) == EOF ) { 144 throw (Close_Failure){ os }; 145 // abort | IO_MSG "close output" | nl | strerror( errno ); 144 abort | IO_MSG "close output" | nl | strerror( errno ); 146 145 } // if 147 146 os.file$ = 0p; … … 150 149 ofstream & write( ofstream & os, const char data[], size_t size ) { 151 150 if ( fail( os ) ) { 152 throw (Write_Failure){ os }; 153 // abort | IO_MSG "attempt write I/O on failed stream"; 151 abort | IO_MSG "attempt write I/O on failed stream"; 154 152 } // if 155 153 156 154 if ( fwrite( data, 1, size, (FILE *)(os.file$) ) != size ) { 157 throw (Write_Failure){ os }; 158 // abort | IO_MSG "write" | nl | strerror( errno ); 155 abort | IO_MSG "write" | nl | strerror( errno ); 159 156 } // if 160 157 return os; … … 280 277 281 278 if ( fclose( (FILE *)(is.file$) ) == EOF ) { 282 throw (Close_Failure){ is }; 283 // abort | IO_MSG "close input" | nl | strerror( errno ); 279 abort | IO_MSG "close input" | nl | strerror( errno ); 284 280 } // if 285 281 is.file$ = 0p; … … 288 284 ifstream & read( ifstream & is, char data[], size_t size ) { 289 285 if ( fail( is ) ) { 290 throw (Read_Failure){ is }; 291 // abort | IO_MSG "attempt read I/O on failed stream"; 286 abort | IO_MSG "attempt read I/O on failed stream"; 292 287 } // if 293 288 294 289 if ( fread( data, size, 1, (FILE *)(is.file$) ) == 0 ) { 295 throw (Read_Failure){ is }; 296 // abort | IO_MSG "read" | nl | strerror( errno ); 290 abort | IO_MSG "read" | nl | strerror( errno ); 297 291 } // if 298 292 return is; … … 344 338 345 339 346 static vtable(Open_Failure) Open_Failure_vt; 340 //EHM_VIRTUAL_TABLE(Open_Failure, Open_Failure_main_table); 341 static vtable(Open_Failure) Open_Failure_main_table; 347 342 348 343 // exception I/O constructors 349 344 void ?{}( Open_Failure & this, ofstream & ostream ) { 350 this.virtual_table = &Open_Failure_ vt;345 this.virtual_table = &Open_Failure_main_table; 351 346 this.ostream = &ostream; 352 347 this.tag = 1; … … 354 349 355 350 void ?{}( Open_Failure & this, ifstream & istream ) { 356 this.virtual_table = &Open_Failure_ vt;351 this.virtual_table = &Open_Failure_main_table; 357 352 this.istream = &istream; 358 353 this.tag = 0; 359 354 } // ?{} 360 355 361 362 static vtable(Close_Failure) Close_Failure_vt; 363 364 // exception I/O constructors 365 void ?{}( Close_Failure & this, ofstream & ostream ) { 366 this.virtual_table = &Close_Failure_vt; 367 this.ostream = &ostream; 368 this.tag = 1; 369 } // ?{} 370 371 void ?{}( Close_Failure & this, ifstream & istream ) { 372 this.virtual_table = &Close_Failure_vt; 373 this.istream = &istream; 374 this.tag = 0; 375 } // ?{} 376 377 378 static vtable(Write_Failure) Write_Failure_vt; 379 380 // exception I/O constructors 381 void ?{}( Write_Failure & this, ofstream & ostream ) { 382 this.virtual_table = &Write_Failure_vt; 383 this.ostream = &ostream; 384 this.tag = 1; 385 } // ?{} 386 387 void ?{}( Write_Failure & this, ifstream & istream ) { 388 this.virtual_table = &Write_Failure_vt; 389 this.istream = &istream; 390 this.tag = 0; 391 } // ?{} 392 393 394 static vtable(Read_Failure) Read_Failure_vt; 395 396 // exception I/O constructors 397 void ?{}( Read_Failure & this, ofstream & ostream ) { 398 this.virtual_table = &Read_Failure_vt; 399 this.ostream = &ostream; 400 this.tag = 1; 401 } // ?{} 402 403 void ?{}( Read_Failure & this, ifstream & istream ) { 404 this.virtual_table = &Read_Failure_vt; 405 this.istream = &istream; 406 this.tag = 0; 407 } // ?{} 408 409 // void throwOpen_Failure( ofstream & ostream ) { 410 // Open_Failure exc = { ostream }; 411 // } 412 413 // void throwOpen_Failure( ifstream & istream ) { 414 // Open_Failure exc = { istream }; 415 // } 356 void throwOpen_Failure( ofstream & ostream ) { 357 Open_Failure exc = { ostream }; 358 } 359 360 void throwOpen_Failure( ifstream & istream ) { 361 Open_Failure exc = { istream }; 362 } 416 363 417 364 // Local Variables: // -
libcfa/src/fstream.hfa
r06c61e2 r9a3a313 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jul 28 07:35:50202113 // Update Count : 23 412 // Last Modified On : Tue Jul 20 21:18:03 2021 13 // Update Count : 232 14 14 // 15 15 … … 160 160 void ?{}( Open_Failure & this, ifstream & ); 161 161 162 exception Close_Failure {163 union {164 ofstream * ostream;165 ifstream * istream;166 };167 // TEMPORARY: need polymorphic exceptions168 int tag; // 1 => ostream; 0 => istream169 };170 171 void ?{}( Close_Failure & this, ofstream & );172 void ?{}( Close_Failure & this, ifstream & );173 174 exception Write_Failure {175 union {176 ofstream * ostream;177 ifstream * istream;178 };179 // TEMPORARY: need polymorphic exceptions180 int tag; // 1 => ostream; 0 => istream181 };182 183 void ?{}( Write_Failure & this, ofstream & );184 void ?{}( Write_Failure & this, ifstream & );185 186 exception Read_Failure {187 union {188 ofstream * ostream;189 ifstream * istream;190 };191 // TEMPORARY: need polymorphic exceptions192 int tag; // 1 => ostream; 0 => istream193 };194 195 void ?{}( Read_Failure & this, ofstream & );196 void ?{}( Read_Failure & this, ifstream & );197 198 162 // Local Variables: // 199 163 // mode: c //
Note:
See TracChangeset
for help on using the changeset viewer.