86 string firstPartWithoutEndingSlash;
87 if (firstPart[firstPart.length()-1]==
'/')
88 firstPartWithoutEndingSlash = firstPart.substr(0,firstPart.length()-1);
90 firstPartWithoutEndingSlash = firstPart;
91 string recondPartWithoutStartingSlash;
92 if (secondPart[0]==
'/')
93 recondPartWithoutStartingSlash = secondPart.substr(1, secondPart.length()-1);
95 recondPartWithoutStartingSlash = secondPart;
96 return firstPartWithoutEndingSlash +
"/" + recondPartWithoutStartingSlash;
103 int err = stat(p.c_str(), &DirInfo);
104 bool isDir = S_ISDIR(DirInfo.st_mode);
105 if ((err!=0)|| !isDir)
107 cerr<<
"Either does not exist or is not directory: File " << p<<
" Err: "<< err <<
" isDir: " << isDir <<
" mode: "<<DirInfo.st_mode<<
" Error: " << strerror(errno) << endl;
109 return (err == 0) &&
isDir;
116 int err = stat(p.c_str(), &DirInfo);
123 int err = stat(p.c_str(), &DirInfo);
125 cerr <<
"Tried to get file size when file does not exist!" << endl;
126 return DirInfo.st_size;
131 vector<string> validFiles;
134 testDir = opendir(directory.c_str());
135 while ((entry = readdir(testDir)))
137 string fullPath = combinePaths(directory,
string(entry->d_name));
140 bool err = (stat(fullPath.c_str(), &dirInfo) != 0);
141 bool isDir = S_ISDIR(dirInfo.st_mode);
142 bool aFile = !(err ||
isDir);
144 validFiles.push_back(fullPath);
156 for (
unsigned int var = 0; var < toTest.length(); var++)
158 if (toTest[var] !=
'0' && toTest[var] >=
' ')
bool isDir(const char *path)
static bool existsAndIsDir(string p)
static string combinePaths(string firstPart, string secondPart)
static bool stringActuallyZero(string toTest)
static bool exists(string p)
static vector< string > getAllFilesInDir(string directory)
static FileOffset getFileSize(string p)