Changeset 58fe85a for libcfa/src/fstream.cfa
- Timestamp:
- Jan 7, 2021, 3:27:00 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 2b4daf2, 64aeca0
- Parents:
- 3c64c668 (diff), eef8dfb (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
r3c64c668 r58fe85a 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 7 19:01:01202013 // Update Count : 3 6312 // Last Modified On : Fri Jun 19 16:24:54 2020 13 // Update Count : 384 14 14 // 15 15 … … 26 26 27 27 28 // *********************************** ofstream ***********************************28 // *********************************** ofstream *********************************** 29 29 30 30 … … 123 123 #ifdef __CFA_DEBUG__ 124 124 if ( file == 0p ) { 125 abort | IO_MSG "open output file \"" | name | "\"" | nl | strerror( errno ); 125 throw (Open_Failure){ os }; 126 // abort | IO_MSG "open output file \"" | name | "\"" | nl | strerror( errno ); 126 127 } // if 127 128 #endif // __CFA_DEBUG__ … … 134 135 135 136 void close( ofstream & os ) { 136 if ( (FILE *)(os.$file) == stdout || (FILE *)(os.$file) == stderr ) return; 137 if ( (FILE *)(os.$file) == 0p ) return; 138 if ( (FILE *)(os.$file) == (FILE *)stdout || (FILE *)(os.$file) == (FILE *)stderr ) return; 137 139 138 140 if ( fclose( (FILE *)(os.$file) ) == EOF ) { 139 141 abort | IO_MSG "close output" | nl | strerror( errno ); 140 142 } // if 143 os.$file = 0p; 141 144 } // close 142 145 … … 179 182 180 183 181 // *********************************** ifstream ***********************************184 // *********************************** ifstream *********************************** 182 185 183 186 … … 219 222 #ifdef __CFA_DEBUG__ 220 223 if ( file == 0p ) { 221 abort | IO_MSG "open input file \"" | name | "\"" | nl | strerror( errno ); 224 throw (Open_Failure){ is }; 225 // abort | IO_MSG "open input file \"" | name | "\"" | nl | strerror( errno ); 222 226 } // if 223 227 #endif // __CFA_DEBUG__ … … 230 234 231 235 void close( ifstream & is ) { 232 if ( (FILE *)(is.$file) == stdin ) return; 236 if ( (FILE *)(is.$file) == 0p ) return; 237 if ( (FILE *)(is.$file) == (FILE *)stdin ) return; 233 238 234 239 if ( fclose( (FILE *)(is.$file) ) == EOF ) { 235 240 abort | IO_MSG "close input" | nl | strerror( errno ); 236 241 } // if 242 is.$file = 0p; 237 243 } // close 238 244 … … 276 282 ifstream & sin = sinFile, & stdin = sinFile; 277 283 284 285 // *********************************** exceptions *********************************** 286 287 288 void ?{}( Open_Failure & this, ofstream & ostream ) { 289 VTABLE_INIT(this, Open_Failure); 290 this.ostream = &ostream; 291 this.tag = 1; 292 } 293 void ?{}( Open_Failure & this, ifstream & istream ) { 294 VTABLE_INIT(this, Open_Failure); 295 this.istream = &istream; 296 this.tag = 0; 297 } 298 const char * Open_Failure_msg(Open_Failure * this) { 299 return "Open_Failure"; 300 } 301 VTABLE_INSTANCE(Open_Failure)(Open_Failure_msg); 302 void throwOpen_Failure( ofstream & ostream ) { 303 Open_Failure exc = { ostream }; 304 } 305 void throwOpen_Failure( ifstream & istream ) { 306 Open_Failure exc = { istream }; 307 } 308 278 309 // Local Variables: // 279 310 // tab-width: 4 //
Note:
See TracChangeset
for help on using the changeset viewer.