Changeset b7b3e41 for libcfa/src/fstream.cfa
- Timestamp:
- Jun 19, 2023, 1:57:11 PM (2 years ago)
- Branches:
- master
- Children:
- adc73a5
- Parents:
- fa5e1aa5 (diff), 33d4bc8 (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
rfa5e1aa5 rb7b3e41 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Apr 9 14:55:54 202213 // Update Count : 5 1512 // Last Modified On : Sat Jun 17 08:51:12 2023 13 // Update Count : 528 14 14 // 15 15 … … 117 117 } // for 118 118 if ( file == 0p ) { 119 throw ( Open_Failure){ os };119 throw (open_failure){ os }; 120 120 // abort | IO_MSG "open output file \"" | name | "\"" | nl | strerror( errno ); 121 121 } // if … … 137 137 } // for 138 138 if ( ret == EOF ) { 139 throw ( Close_Failure){ os };139 throw (close_failure){ os }; 140 140 // abort | IO_MSG "close output" | nl | strerror( errno ); 141 141 } // if … … 145 145 ofstream & write( ofstream & os, const char data[], size_t size ) { 146 146 if ( fail( os ) ) { 147 throw ( Write_Failure){ os };147 throw (write_failure){ os }; 148 148 // abort | IO_MSG "attempt write I/O on failed stream"; 149 149 } // if 150 150 151 151 if ( fwrite( data, 1, size, (FILE *)(os.file$) ) != size ) { 152 throw ( Write_Failure){ os };152 throw (write_failure){ os }; 153 153 // abort | IO_MSG "write" | nl | strerror( errno ); 154 154 } // if … … 169 169 if ( cnt == 9 ) abort( "ofstream fmt EINTR spinning exceeded" ); 170 170 } // for 171 if ( len == EOF ) { 172 if ( ferror( (FILE *)(os.file$) ) ) { 173 abort | IO_MSG "invalid write"; 174 } // if 171 if ( len == EOF ) { // error writing ? 172 abort | IO_MSG "invalid write"; 175 173 } // if 176 174 va_end( args ); … … 240 238 } // for 241 239 if ( file == 0p ) { 242 throw ( Open_Failure){ is };240 throw (open_failure){ is }; 243 241 // abort | IO_MSG "open input file \"" | name | "\"" | nl | strerror( errno ); 244 242 } // if … … 260 258 } // for 261 259 if ( ret == EOF ) { 262 throw ( Close_Failure){ is };260 throw (close_failure){ is }; 263 261 // abort | IO_MSG "close input" | nl | strerror( errno ); 264 262 } // if … … 268 266 ifstream & read( ifstream & is, char data[], size_t size ) { 269 267 if ( fail( is ) ) { 270 throw ( Read_Failure){ is };268 throw (read_failure){ is }; 271 269 // abort | IO_MSG "attempt read I/O on failed stream"; 272 270 } // if 273 271 274 272 if ( fread( data, size, 1, (FILE *)(is.file$) ) == 0 ) { 275 throw ( Read_Failure){ is };273 throw (read_failure){ is }; 276 274 // abort | IO_MSG "read" | nl | strerror( errno ); 277 275 } // if … … 302 300 if ( len != EOF || errno != EINTR ) break; // timer interrupt ? 303 301 } // for 304 if ( len == EOF ) { 305 if ( ferror( (FILE *)(is.file$) ) ) {302 if ( len == EOF ) { // EOF or matching failure ? 303 if ( ! feof( (FILE *)(is.file$) ) && ferror( (FILE *)(is.file$) ) ) { 306 304 abort | IO_MSG "invalid read"; 307 305 } // if … … 318 316 319 317 320 static vtable( Open_Failure) Open_Failure_vt;318 static vtable(open_failure) open_failure_vt; 321 319 322 320 // exception I/O constructors 323 void ?{}( Open_Failure & ex, ofstream & ostream ) with(ex) {324 virtual_table = & Open_Failure_vt;321 void ?{}( open_failure & ex, ofstream & ostream ) with(ex) { 322 virtual_table = &open_failure_vt; 325 323 ostream = &ostream; 326 324 tag = 1; 327 325 } // ?{} 328 326 329 void ?{}( Open_Failure & ex, ifstream & istream ) with(ex) {330 virtual_table = & Open_Failure_vt;327 void ?{}( open_failure & ex, ifstream & istream ) with(ex) { 328 virtual_table = &open_failure_vt; 331 329 istream = &istream; 332 330 tag = 0; … … 334 332 335 333 336 static vtable( Close_Failure) Close_Failure_vt;334 static vtable(close_failure) close_failure_vt; 337 335 338 336 // exception I/O constructors 339 void ?{}( Close_Failure & ex, ofstream & ostream ) with(ex) {340 virtual_table = & Close_Failure_vt;337 void ?{}( close_failure & ex, ofstream & ostream ) with(ex) { 338 virtual_table = &close_failure_vt; 341 339 ostream = &ostream; 342 340 tag = 1; 343 341 } // ?{} 344 342 345 void ?{}( Close_Failure & ex, ifstream & istream ) with(ex) {346 virtual_table = & Close_Failure_vt;343 void ?{}( close_failure & ex, ifstream & istream ) with(ex) { 344 virtual_table = &close_failure_vt; 347 345 istream = &istream; 348 346 tag = 0; … … 350 348 351 349 352 static vtable( Write_Failure) Write_Failure_vt;350 static vtable(write_failure) write_failure_vt; 353 351 354 352 // exception I/O constructors 355 void ?{}( Write_Failure & ex, ofstream & ostream ) with(ex) {356 virtual_table = & Write_Failure_vt;353 void ?{}( write_failure & ex, ofstream & ostream ) with(ex) { 354 virtual_table = &write_failure_vt; 357 355 ostream = &ostream; 358 356 tag = 1; 359 357 } // ?{} 360 358 361 void ?{}( Write_Failure & ex, ifstream & istream ) with(ex) {362 virtual_table = & Write_Failure_vt;359 void ?{}( write_failure & ex, ifstream & istream ) with(ex) { 360 virtual_table = &write_failure_vt; 363 361 istream = &istream; 364 362 tag = 0; … … 366 364 367 365 368 static vtable( Read_Failure) Read_Failure_vt;366 static vtable(read_failure) read_failure_vt; 369 367 370 368 // exception I/O constructors 371 void ?{}( Read_Failure & ex, ofstream & ostream ) with(ex) {372 virtual_table = & Read_Failure_vt;369 void ?{}( read_failure & ex, ofstream & ostream ) with(ex) { 370 virtual_table = &read_failure_vt; 373 371 ostream = &ostream; 374 372 tag = 1; 375 373 } // ?{} 376 374 377 void ?{}( Read_Failure & ex, ifstream & istream ) with(ex) {378 virtual_table = & Read_Failure_vt;375 void ?{}( read_failure & ex, ifstream & istream ) with(ex) { 376 virtual_table = &read_failure_vt; 379 377 istream = &istream; 380 378 tag = 0; 381 379 } // ?{} 382 380 383 // void throw Open_Failure( ofstream & ostream ) {384 // Open_Failure exc = { ostream };381 // void throwopen_failure( ofstream & ostream ) { 382 // open_failure exc = { ostream }; 385 383 // } 386 384 387 // void throw Open_Failure( ifstream & istream ) {388 // Open_Failure exc = { istream };385 // void throwopen_failure( ifstream & istream ) { 386 // open_failure exc = { istream }; 389 387 // } 390 388
Note:
See TracChangeset
for help on using the changeset viewer.