Changeset b6838214 for src/libcfa/fstream.c
- Timestamp:
- Jan 23, 2018, 5:46:43 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 258e6ad5
- Parents:
- b158d8f (diff), 15d248e (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
-
src/libcfa/fstream.c
rb158d8f rb6838214 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Dec 7 08:35:01201713 // Update Count : 27 012 // Last Modified On : Sat Dec 9 09:31:23 2017 13 // Update Count : 275 14 14 // 15 15 … … 46 46 47 47 // public 48 void ?{}( ofstream & os ) { }48 void ?{}( ofstream & os ) { os.file = 0; } 49 49 50 50 void ?{}( ofstream & os, const char * name, const char * mode ) { 51 51 open( os, name, mode ); 52 } 53 void ?{}( ofstream & os, const char * name ) { 54 open( os, name, "w" ); 52 55 } 53 56 … … 84 87 85 88 int fail( ofstream & os ) { 86 return ferror( (FILE *)(os.file) );89 return os.file == 0 || ferror( (FILE *)(os.file) ); 87 90 } // fail 88 91 … … 93 96 void open( ofstream & os, const char * name, const char * mode ) { 94 97 FILE *file = fopen( name, mode ); 95 if ( file == 0 ) { // do not change unless successful96 fprintf( stderr, IO_MSG "open output file \"%s\", ", name );97 perror( 0 );98 exit( EXIT_FAILURE );99 } // if98 // if ( file == 0 ) { // do not change unless successful 99 // fprintf( stderr, IO_MSG "open output file \"%s\", ", name ); 100 // perror( 0 ); 101 // exit( EXIT_FAILURE ); 102 // } // if 100 103 (os){ file, true, false, " ", ", " }; 104 } // open 105 106 void open( ofstream & os, const char * name ) { 107 open( os, name, "w" ); 101 108 } // open 102 109 … … 152 159 153 160 // public 154 void ?{}( ifstream & is ) {} 155 161 void ?{}( ifstream & is ) { is.file = 0; } 162 163 void ?{}( ifstream & is, const char * name, const char * mode ) { 164 open( is, name, mode ); 165 } 156 166 void ?{}( ifstream & is, const char * name ) { 157 open( is, name );167 open( is, name, "r" ); 158 168 } 159 169 160 170 int fail( ifstream & is ) { 161 return ferror( (FILE *)(is.file) );171 return is.file == 0 || ferror( (FILE *)(is.file) ); 162 172 } // fail 163 173 … … 166 176 } // eof 167 177 178 void open( ifstream & is, const char * name, const char * mode ) { 179 FILE *file = fopen( name, mode ); 180 // if ( file == 0 ) { // do not change unless successful 181 // fprintf( stderr, IO_MSG "open input file \"%s\", ", name ); 182 // perror( 0 ); 183 // exit( EXIT_FAILURE ); 184 // } // if 185 is.file = file; 186 } // open 187 168 188 void open( ifstream & is, const char * name ) { 169 FILE *file = fopen( name, "r" ); 170 if ( file == 0 ) { // do not change unless successful 171 fprintf( stderr, IO_MSG "open input file \"%s\", ", name ); 172 perror( 0 ); 173 exit( EXIT_FAILURE ); 174 } // if 175 is.file = file; 189 open( is, name, "r" ); 176 190 } // open 177 191
Note: See TracChangeset
for help on using the changeset viewer.