Changeset 0a061c0 for libcfa/src/fstream.cfa
- Timestamp:
- Aug 4, 2021, 4:54:14 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- d2cdd4f
- Parents:
- d83b266 (diff), 199894e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/fstream.cfa
rd83b266 r0a061c0 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 2 11:34:41202113 // Update Count : 4 4812 // Last Modified On : Thu Jul 29 22:34:10 2021 13 // Update Count : 454 14 14 // 15 15 … … 142 142 143 143 if ( fclose( (FILE *)(os.file$) ) == EOF ) { 144 abort | IO_MSG "close output" | nl | strerror( errno ); 144 throw (Close_Failure){ os }; 145 // abort | IO_MSG "close output" | nl | strerror( errno ); 145 146 } // if 146 147 os.file$ = 0p; … … 149 150 ofstream & write( ofstream & os, const char data[], size_t size ) { 150 151 if ( fail( os ) ) { 151 abort | IO_MSG "attempt write I/O on failed stream"; 152 throw (Write_Failure){ os }; 153 // abort | IO_MSG "attempt write I/O on failed stream"; 152 154 } // if 153 155 154 156 if ( fwrite( data, 1, size, (FILE *)(os.file$) ) != size ) { 155 abort | IO_MSG "write" | nl | strerror( errno ); 157 throw (Write_Failure){ os }; 158 // abort | IO_MSG "write" | nl | strerror( errno ); 156 159 } // if 157 160 return os; … … 277 280 278 281 if ( fclose( (FILE *)(is.file$) ) == EOF ) { 279 abort | IO_MSG "close input" | nl | strerror( errno ); 282 throw (Close_Failure){ is }; 283 // abort | IO_MSG "close input" | nl | strerror( errno ); 280 284 } // if 281 285 is.file$ = 0p; … … 284 288 ifstream & read( ifstream & is, char data[], size_t size ) { 285 289 if ( fail( is ) ) { 286 abort | IO_MSG "attempt read I/O on failed stream"; 290 throw (Read_Failure){ is }; 291 // abort | IO_MSG "attempt read I/O on failed stream"; 287 292 } // if 288 293 289 294 if ( fread( data, size, 1, (FILE *)(is.file$) ) == 0 ) { 290 abort | IO_MSG "read" | nl | strerror( errno ); 295 throw (Read_Failure){ is }; 296 // abort | IO_MSG "read" | nl | strerror( errno ); 291 297 } // if 292 298 return is; … … 338 344 339 345 340 //EHM_VIRTUAL_TABLE(Open_Failure, Open_Failure_main_table); 341 static vtable(Open_Failure) Open_Failure_main_table; 346 static vtable(Open_Failure) Open_Failure_vt; 342 347 343 348 // exception I/O constructors 344 349 void ?{}( Open_Failure & this, ofstream & ostream ) { 345 this.virtual_table = &Open_Failure_ main_table;350 this.virtual_table = &Open_Failure_vt; 346 351 this.ostream = &ostream; 347 352 this.tag = 1; … … 349 354 350 355 void ?{}( Open_Failure & this, ifstream & istream ) { 351 this.virtual_table = &Open_Failure_ main_table;356 this.virtual_table = &Open_Failure_vt; 352 357 this.istream = &istream; 353 358 this.tag = 0; 354 359 } // ?{} 355 360 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 } 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 // } 363 416 364 417 // Local Variables: //
Note: See TracChangeset
for help on using the changeset viewer.