/***********************************************************************/
inline string getFullPathName(string fileName){
-
+ try{
string path = hasPath(fileName);
string newFileName;
int pos;
if (path.rfind("./") == -1) { return fileName; } //already complete name
else { newFileName = fileName.substr(fileName.rfind("./")+2); } //save the complete part of the name
- char* cwdpath;
+ char* cwdpath = new char[1024];
+
size_t size;
cwdpath=getcwd(cwdpath,size);
- cwd = cwdpath;
+ cwd = cwdpath;
+
//rip off first '/'
string simpleCWD;
if (cwd.length() > 0) { simpleCWD = cwd.substr(1); }
}
//get last one // ex. ../../../filename = /user/work/desktop/filename
dirs.push_back(simpleCWD); //ex. dirs[0] = user, dirs[1] = work, dirs[2] = desktop
-
+
+
int index = dirs.size()-1;
-
+
while((pos = path.rfind("./")) != -1) { //while you don't have a complete path
if (path[(pos-1)] == '.') { //you want your parent directory ../
path = path.substr(0, pos-1);
#endif
}
+ }
+ catch(exception& e) {
+ errorOut(e, "getFullPathName", "getFullPathName");
+ exit(1);
+ }
+
}
/***********************************************************************/
inline int openInputFile(string fileName, ifstream& fileHandle){
//get full path name
string completeFileName = getFullPathName(fileName);
-
+
fileHandle.open(completeFileName.c_str());
if(!fileHandle) {
mothurOut("Error: Could not open " + completeFileName); mothurOutEndLine();
system(command.c_str());
#else
remove(newName.c_str());
- renameOk = rename(oldName.c_str(), newName.c_str());
+ int renameOk = rename(oldName.c_str(), newName.c_str());
#endif
return 0;
}
exit(1);
}
}
+/**************************************************************************************************/
+//returns true if any of the strings in first vector are in second vector
+inline bool inUsersGroups(vector<string> groupnames, vector<string> Groups) {
+ try {
+
+ for (int i = 0; i < groupnames.size(); i++) {
+ if (inUsersGroups(groupnames[i], Groups)) { return true; }
+ }
+ return false;
+ }
+ catch(exception& e) {
+ errorOut(e, "mothur", "inUsersGroups");
+ exit(1);
+ }
+}
/**************************************************************************************************/