Changeset 8da74119
- Timestamp:
- Dec 9, 2017, 12:10:04 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:
- 32a1d654
- Parents:
- 5e1adb5
- Location:
- src/libcfa
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/fstream
r5e1adb5 r8da74119 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:06:11201713 // Update Count : 1 2912 // Last Modified On : Thu Dec 7 15:17:26 2017 13 // Update Count : 130 14 14 // 15 15 … … 52 52 int flush( ofstream & ); 53 53 void open( ofstream &, const char * name, const char * mode ); 54 void open( ofstream &, const char * name ); 54 55 void close( ofstream & ); 55 56 ofstream & write( ofstream &, const char * data, unsigned long int size ); … … 58 59 void ?{}( ofstream & os ); 59 60 void ?{}( ofstream & os, const char * name, const char * mode ); 61 void ?{}( ofstream & os, const char * name ); 60 62 61 63 extern ofstream & sout, & serr; … … 69 71 int fail( ifstream & is ); 70 72 int eof( ifstream & is ); 73 void open( ifstream & is, const char * name, const char * mode ); 71 74 void open( ifstream & is, const char * name ); 72 75 void close( ifstream & is ); … … 76 79 77 80 void ?{}( ifstream & is ); 81 void ?{}( ifstream & is, const char * name, const char * mode ); 78 82 void ?{}( ifstream & is, const char * name ); 79 83 -
src/libcfa/fstream.c
r5e1adb5 r8da74119 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.