]> git.donarmstrong.com Git - mothur.git/blobdiff - setdircommand.cpp
fixed bug with shhh.flow from file path name in write functions, added "smart" featur...
[mothur.git] / setdircommand.cpp
index 17bad60d2f358b41d4dce9eeafc6a155ad069df7..67a1f59f8388dbfec55ae7b552f02640b5d6b93f 100644 (file)
@@ -202,8 +202,19 @@ int SetDirectoryCommand::execute(){
                                if (lastChar != "\\") { tempdefault += "\\"; }  
                        #endif
                        
-                       m->mothurOut("tempDefault=" + tempdefault); m->mothurOutEndLine();  
-                       m->setDefaultPath(tempdefault);
+                       //test to make sure directory exists
+                       tempdefault = m->getFullPathName(tempdefault);
+                       string inTemp = tempdefault + tag + "temp";
+                       ofstream in;
+                       in.open(inTemp.c_str(), ios::trunc);
+                       if(!in) {
+                               m->mothurOut(tempdefault + " directory does not exist or is not writable."); m->mothurOutEndLine(); 
+                       }else{
+                               in.close();
+                               m->mothurRemove(inTemp);
+                               m->mothurOut("tempDefault=" + tempdefault); m->mothurOutEndLine();  
+                               m->setDefaultPath(tempdefault);
+                       }
                }
 
                return 0;