]> git.donarmstrong.com Git - mothur.git/blobdiff - mothur.h
added check for blank files in openInputFile, add check for groupfiles that contain...
[mothur.git] / mothur.h
index ed206af809e4f369b12015ed0406966d12992a72..836e0660dae78b87fe71e20bc95f59506c81d5dd 100644 (file)
--- a/mothur.h
+++ b/mothur.h
@@ -171,6 +171,16 @@ inline int openOutputFileAppend(string fileName, ofstream& fileHandle){
 }
 /***********************************************************************/
 
+inline void gobble(istream& f){
+       
+       char d;
+    while(isspace(d=f.get()))          {;}
+       f.putback(d);
+       
+}
+
+/***********************************************************************/
+
 inline string getline(ifstream& fileHandle) {
        try {
        
@@ -181,7 +191,7 @@ inline string getline(ifstream& fileHandle) {
                        char c = fileHandle.get(); 
                        
                        //are you at the end of the line
-                       if ((c == '\n') || (c == '\r') || (c == '\f')){   break;        }       
+                       if ((c == '\n') || (c == '\r') || (c == '\f')){  break; }       
                        else {          line += c;              }
                }
                
@@ -257,7 +267,7 @@ inline void errorOut(exception& e, string object, string function) {
        
                mothurOut("Error: ");
                mothurOut(toString(e.what()));
-               mothurOut(" has occurred in the " + object + " class function " + function + ". Please contact Pat Schloss at pschloss@microbio.umass.edu, and be sure to include the mothur.logFile with your inquiry.");
+               mothurOut(" has occurred in the " + object + " class function " + function + ". Please contact Pat Schloss at pschloss@umich.edu, and be sure to include the mothur.logFile with your inquiry.");
                mothurOutEndLine();
        
 }
@@ -265,15 +275,6 @@ inline void errorOut(exception& e, string object, string function) {
 
 
 
-/***********************************************************************/
-
-inline void gobble(istream& f){
-       
-       char d;
-    while(isspace(d=f.get()))          {;}
-       f.putback(d);
-       
-}
 /***********************************************************************/
 
 inline bool isTrue(string f){
@@ -424,6 +425,10 @@ inline int openInputFile(string fileName, ifstream& fileHandle){
                return 1;
        }
        else {
+               //check for blank file
+               gobble(fileHandle);
+               if (fileHandle.eof()) { mothurOut(fileName + " is blank. Please correct."); mothurOutEndLine();  return 1;  }
+               
                return 0;
        }