InteractEngine::InteractEngine(string path){
globaldata = GlobalData::getInstance();
- globaldata->argv = path;
+ string temppath = path.substr(0, (path.find_last_of('m')));
+
+ //this will happen if you set the path variable to contain mothur's exe location
+ if (temppath == "") {
+
+ string envPath = getenv("PATH");
+
+ //delimiting path char
+ char delim;
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+ delim = ':';
+ #else
+ delim = ';';
+ #endif
+
+ //break apart path variable by ':'
+ vector<string> dirs;
+ mout->splitAtChar(envPath, dirs, delim);
+
+ //get path related to mothur
+ string mothurPath = "";
+ for (int i = 0; i < dirs.size(); i++) {
+ //to lower so we can find it
+ string tempLower = "";
+ for (int j = 0; j < dirs[i].length(); j++) { tempLower += tolower(dirs[i][j]); }
+
+ //is this mothurs path?
+ if (tempLower.find("mothur") != -1) { mothurPath = dirs[i]; break; }
+ }
+
+ //add mothur so it looks like what argv would look like
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+ mothurPath += "/mothur";
+ #else
+ mothurPath += "\\mothur";
+ #endif
+
+ path = mothurPath;
+ }
+
+ globaldata->argv = path;
}
/***********************************************************************/
try {
globaldata = GlobalData::getInstance();
- openedBatch = openInputFile(batchFileName, inputBatchFile);
+ openedBatch = mout->openInputFile(batchFileName, inputBatchFile);
+
+ string temppath = path.substr(0, (path.find_last_of('m')));
+
+ //this will happen if you set the path variable to contain mothur's exe location
+ if (temppath == "") {
+
+ string envPath = getenv("PATH");
+
+ //delimiting path char
+ char delim;
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+ delim = ':';
+ #else
+ delim = ';';
+ #endif
+
+ //break apart path variable by ':'
+ vector<string> dirs;
+ mout->splitAtChar(envPath, dirs, delim);
+
+ //get path related to mothur
+ string mothurPath = "";
+ for (int i = 0; i < dirs.size(); i++) {
+ //to lower so we can find it
+ string tempLower = "";
+ for (int j = 0; j < dirs[i].length(); j++) { tempLower += tolower(dirs[i][j]); }
+
+ //is this mothurs path?
+ if (tempLower.find("mothur") != -1) { mothurPath = dirs[i]; break; }
+ }
+
+ //add mothur so it looks like what argv would look like
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+ mothurPath += "/mothur";
+ #else
+ mothurPath += "\\mothur";
+ #endif
+
+ path = mothurPath;
+ }
+
globaldata->argv = path;
}
}
}
- gobble(inputBatchFile);
+ mout->gobble(inputBatchFile);
}
inputBatchFile.close();
string nextcommand = "";
if (inputBatchFile.eof()) { nextcommand = "quit()"; }
- else { nextcommand = getline(inputBatchFile); }
+ else { nextcommand = mout->getline(inputBatchFile); }
return nextcommand;
}
//remove quotes
listOfCommands = commandString.substr(1, (commandString.length()-1));
+
+ string temppath = path.substr(0, (path.find_last_of('m')));
+
+ //this will happen if you set the path variable to contain mothur's exe location
+ if (temppath == "") {
+
+ string envPath = getenv("PATH");
+
+ //delimiting path char
+ char delim;
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+ delim = ':';
+ #else
+ delim = ';';
+ #endif
+
+ //break apart path variable by ':'
+ vector<string> dirs;
+ mout->splitAtChar(envPath, dirs, delim);
+
+ //get path related to mothur
+ string mothurPath = "";
+ for (int i = 0; i < dirs.size(); i++) {
+ //to lower so we can find it
+ string tempLower = "";
+ for (int j = 0; j < dirs[i].length(); j++) { tempLower += tolower(dirs[i][j]); }
+
+ //is this mothurs path?
+ if (tempLower.find("mothur") != -1) { mothurPath = dirs[i]; break; }
+ }
+
+ //add mothur so it looks like what argv would look like
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+ mothurPath += "/mothur";
+ #else
+ mothurPath += "\\mothur";
+ #endif
+
+ path = mothurPath;
+ }
globaldata->argv = path;
string nextcommand = "";
int count = 0;
+ bool ignoreSemiColons = false;
//go through string until you reach ; or end
while (count < commandString.length()) {
- if (commandString[count] == ';') { break; }
+ //you want to ignore any ; until you reach the next '
+ if ((commandString[count] == '\'') && (!ignoreSemiColons)) { ignoreSemiColons = true; }
+ else if ((commandString[count] == '\'') && (ignoreSemiColons)) { ignoreSemiColons = false; }
+
+ if ((commandString[count] == ';') && (!ignoreSemiColons)) { break; }
else { nextcommand += commandString[count]; }
count++;