m->mothurOut("outputDir=" + output); m->mothurOutEndLine();
commandFactory->setOutputDirectory(output);
}else {
- //add / to name if needed
- string lastChar = output.substr(output.length()-1);
- #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
- if (lastChar != "/") { output += "/"; }
- #else
- if (lastChar != "\\") { output += "\\"; }
- #endif
-
- //test to make sure directory exists
- output = m->getFullPathName(output);
- string outTemp = output + "temp";
- ofstream out;
- out.open(outTemp.c_str(), ios::trunc);
- if(!out) {
- m->mothurOut(output + " directory does not exist or is not writable."); m->mothurOutEndLine();
- }else{
- out.close();
- remove(outTemp.c_str());
- m->mothurOut("outputDir=" + output); m->mothurOutEndLine();
+ if (m->dirCheck(output)) {
+ m->mothurOut("outputDir=" + output); m->mothurOutEndLine();
commandFactory->setOutputDirectory(output);
- }
+ }
}
//redirect input
m->mothurOut("inputDir=" + input); m->mothurOutEndLine();
commandFactory->setInputDirectory(input);
}else {
- //add / to name if needed
- string lastChar = input.substr(input.length()-1);
- #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
- if (lastChar != "/") { input += "/"; }
- #else
- if (lastChar != "\\") { input += "\\"; }
- #endif
-
- //test to make sure directory exists
- input = m->getFullPathName(input);
- string inTemp = input + "temp";
- ofstream in;
- in.open(inTemp.c_str(), ios::trunc);
- if(!in) {
- m->mothurOut(input + " directory does not exist or is not writable."); m->mothurOutEndLine();
- }else{
- in.close();
- remove(inTemp.c_str());
- m->mothurOut("inputDir=" + input); m->mothurOutEndLine();
+ if (m->dirCheck(input)) {
+ m->mothurOut("inputDir=" + input); m->mothurOutEndLine();
commandFactory->setInputDirectory(input);
- }
- }
+ }
+ }
//set default
if (tempdefault == "clear") {
m->mothurOut("tempDefault=" + tempdefault); m->mothurOutEndLine();
m->setDefaultPath(tempdefault);
}else {
- //add / to name if needed
- string lastChar = tempdefault.substr(tempdefault.length()-1);
- #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
- if (lastChar != "/") { tempdefault += "/"; }
- #else
- if (lastChar != "\\") { tempdefault += "\\"; }
- #endif
-
- m->mothurOut("tempDefault=" + tempdefault); m->mothurOutEndLine();
- m->setDefaultPath(tempdefault);
- }
+ if (m->dirCheck(tempdefault)) {
+ m->mothurOut("tempDefault=" + tempdefault); m->mothurOutEndLine();
+ m->setDefaultPath(tempdefault);
+ }
+ }
return 0;
}