]> git.donarmstrong.com Git - mothur.git/blobdiff - mothurout.cpp
fixed bug with windows version of trim.seqs when run with 1 processor. fixed file...
[mothur.git] / mothurout.cpp
index 98f5ce09608855690a9fc7442814841a064db379..d5f1534f7535052c75888b04d28211fd522a0410 100644 (file)
@@ -598,6 +598,48 @@ string MothurOut::getPathName(string longName){
 }
 /***********************************************************************/
 
+bool MothurOut::dirCheck(string& dirName){
+       try {
+        
+        string tag = "";
+        #ifdef USE_MPI
+            int pid; 
+            MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
+               
+            tag = toString(pid);
+        #endif
+
+        //add / to name if needed
+        string lastChar = dirName.substr(dirName.length()-1);
+        #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
+        if (lastChar != "/") { dirName += "/"; }
+        #else
+        if (lastChar != "\\") { dirName += "\\"; }     
+        #endif
+
+        //test to make sure directory exists
+        dirName = getFullPathName(dirName);
+        string outTemp = dirName + tag + "temp";
+        ofstream out;
+        out.open(outTemp.c_str(), ios::trunc);
+        if(!out) {
+            mothurOut(dirName + " directory does not exist or is not writable."); mothurOutEndLine(); 
+        }else{
+            out.close();
+            mothurRemove(outTemp);
+            return true;
+        }
+        
+        return false;
+    }
+       catch(exception& e) {
+               errorOut(e, "MothurOut", "dirCheck");
+               exit(1);
+       }       
+    
+}
+/***********************************************************************/
+
 string MothurOut::hasPath(string longName){
        try {
                string path = "";