r2296 - alfs-POC/src

jhuntwork at linuxfromscratch.org jhuntwork at linuxfromscratch.org
Thu Mar 2 11:28:36 PST 2006


Author: jhuntwork
Date: 2006-03-02 12:28:36 -0700 (Thu, 02 Mar 2006)
New Revision: 2296

Modified:
   alfs-POC/src/parser.cpp
Log:
Fix the way files are opened - will correctly bail on error now.

Modified: alfs-POC/src/parser.cpp
===================================================================
--- alfs-POC/src/parser.cpp	2006-03-02 19:20:47 UTC (rev 2295)
+++ alfs-POC/src/parser.cpp	2006-03-02 19:28:36 UTC (rev 2296)
@@ -50,7 +50,7 @@
   file = fn.c_str();
   fp.open(file);
   if (!fp)
-    cerr << "Cannot open file: " << fn << endl;
+    perror(file);
 
   /* Set the current working directory, in case we leave it,
      and so we can get the name of the parent directory for
@@ -59,7 +59,7 @@
 
   /* Read one line at a time from the opened file
      until the end of the file is reached */
-  while (!fp.eof()) {
+  while (fp.good()) {
     getline(fp, curline);
     cout << "Current line: " << curline << endl;	
   }




More information about the alfs-log mailing list