}
}
/*********************************************************************************************/
+void MothurOut::setOutputDir(string pathname) {
+ try {
+ outputDir = pathname;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "setOutputDir");
+ exit(1);
+ }
+}
+/*********************************************************************************************/
void MothurOut::closeLog() {
try {
#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
if (path.find("~") != -1) { //go to home directory
- string homeDir = getenv ("HOME");
+ string homeDir;
+
+ char *homepath = NULL;
+ homepath = getenv ("HOME");
+ if ( homepath != NULL) { homeDir = homepath; }
+ else { homeDir = ""; }
+
newFileName = homeDir + fileName.substr(fileName.find("~")+1);
return newFileName;
}else { //find path
- if (path.rfind("./") == -1) { return fileName; } //already complete name
+ if (path.rfind("./") == string::npos) { return fileName; } //already complete name
else { newFileName = fileName.substr(fileName.rfind("./")+2); } //save the complete part of the name
- char* cwdpath = new char[1024];
+ //char* cwdpath = new char[1024];
+ //size_t size;
+ //cwdpath=getcwd(cwdpath,size);
+ //cwd = cwdpath;
+
+ char *cwdpath = NULL;
+ cwdpath = getcwd(NULL, 0); // or _getcwd
+ if ( cwdpath != NULL) { cwd = cwdpath; }
+ else { cwd = ""; }
- size_t size;
- cwdpath=getcwd(cwdpath,size);
-
- cwd = cwdpath;
//rip off first '/'
string simpleCWD;
//break apart the current working directory
vector<string> dirs;
- while (simpleCWD.find_first_of('/') != -1) {
+ while (simpleCWD.find_first_of('/') != string::npos) {
string dir = simpleCWD.substr(0,simpleCWD.find_first_of('/'));
simpleCWD = simpleCWD.substr(simpleCWD.find_first_of('/')+1, simpleCWD.length());
dirs.push_back(dir);
int index = dirs.size()-1;
- while((pos = path.rfind("./")) != -1) { //while you don't have a complete path
+ while((pos = path.rfind("./")) != string::npos) { //while you don't have a complete path
if (pos == 0) { break; //you are at the end
}else if (path[(pos-1)] == '.') { //you want your parent directory ../
path = path.substr(0, pos-1);
return newFileName;
}
#else
- if (path.find("~") != -1) { //go to home directory
+ if (path.find("~") != string::npos) { //go to home directory
string homeDir = getenv ("HOMEPATH");
newFileName = homeDir + fileName.substr(fileName.find("~")+1);
return newFileName;
}else { //find path
- if (path.rfind(".\\") == -1) { return fileName; } //already complete name
+ if (path.rfind(".\\") == string::npos) { return fileName; } //already complete name
else { newFileName = fileName.substr(fileName.rfind(".\\")+2); } //save the complete part of the name
char *cwdpath = NULL;
int index = dirs.size()-1;
- while((pos = path.rfind(".\\")) != -1) { //while you don't have a complete path
+ while((pos = path.rfind(".\\")) != string::npos) { //while you don't have a complete path
if (pos == 0) { break; //you are at the end
}else if (path[(pos-1)] == '.') { //you want your parent directory ../
path = path.substr(0, pos-1);
fileHandle.open(completeFileName.c_str());
if(!fileHandle) {
+ //mothurOut("[ERROR]: Could not open " + completeFileName); mothurOutEndLine();
return 1;
}else {
//check for blank file
//open output file in append mode
openOutputFileAppend(filename, output);
int ableToOpen = openInputFile(temp, input, "no error");
+ //int ableToOpen = openInputFile(temp, input);
if (ableToOpen == 0) { //you opened it
while(char c = input.get()){
//sanity check filePos
for (int i = 0; i < (filePos.size()-1); i++) {
- if (filePos[(i+1)] <= filePos[i]) { cout << "erasing " << (i+1) << endl; filePos.erase(filePos.begin()+(i+1)); i--; }
+ if (filePos[(i+1)] <= filePos[i]) { filePos.erase(filePos.begin()+(i+1)); i--; }
}
proc = (filePos.size() - 1);
//This function parses the estimator options and puts them in a vector
void MothurOut::splitAtChar(string& estim, vector<string>& container, char symbol) {
try {
- string individual;
+ string individual = "";
+ int estimLength = estim.size();
+ for(int i=0;i<estimLength;i++){
+ if(estim[i] == symbol){
+ container.push_back(individual);
+ individual = "";
+ }
+ else{
+ individual += estim[i];
+ }
+ }
+ container.push_back(individual);
+
+ /*
while (estim.find_first_of(symbol) != -1) {
individual = estim.substr(0,estim.find_first_of(symbol));
}
}
//get last one
- container.push_back(estim);
+ container.push_back(estim); */
}
catch(exception& e) {
errorOut(e, "MothurOut", "splitAtChar");
exit(1);
}
}
+
/**************************************************************************************************/