Changeset 527 for CMT/HEAD/source/cmt_system.cxx
- Timestamp:
- Nov 20, 2009, 10:45:54 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
CMT/HEAD/source/cmt_system.cxx
r515 r527 528 528 { 529 529 s1.write (f); 530 fclose (f); 530 if (ferror (f)) 531 return (false); 532 if (fclose (f)) 533 return (false); 531 534 532 535 unlink (name1); … … 2419 2422 } 2420 2423 2421 2422 2423 2424 //---------------------------------------------------------- 2425 void CmtSystem::close_ostream (FILE *stream, const cmt_string& name) 2426 { 2427 cmt_string msg ("Cannot write"); 2428 cmt_string n = (name != "") ? " " + name : ""; 2429 if (stream == NULL) 2430 { 2431 CmtMessage::error (msg + n); 2432 exit (EXIT_FAILURE); 2433 } 2434 2435 bool prev_fail = ferror (stream); 2436 bool fclose_fail = fclose (stream); 2437 2438 if (prev_fail || fclose_fail) 2439 { 2440 int err = fclose_fail ? errno : 0; 2441 cmt_string e = err ? ": " + cmt_string (strerror (err)) : ""; 2442 CmtMessage::error (msg + n + e); 2443 exit (EXIT_FAILURE); 2444 } 2445 } 2446 2447 //---------------------------------------------------------- 2448 void CmtSystem::close_stdout (void) 2449 { 2450 /* 2451 * The idea and, to some extent, implementation of this function 2452 * was borrowed from the GNU core utilities of the Free Software Foundation 2453 * http://www.gnu.org/software/coreutils/ 2454 */ 2455 close_ostream (stdout, "stdout"); 2456 } 2424 2457 2425 2458 //----------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.