| 205 | } |
| 206 | |
| 207 | bool LinuxAddFileStack(const char* szPathName, const char* fileMask, |
| 208 | bool bRecursive, std::vector<std::string> &list, |
| 209 | bool justDirs = false) { |
| 210 | DIR* directory; |
| 211 | dirent* fileInfo; |
| 212 | struct stat statbuf; |
| 213 | char searchstr[1024]; |
| 214 | std::string FilePath; |
| 215 | |
| 216 | strcpy(searchstr, szPathName); |
| 217 | if (searchstr[strlen(searchstr) - 1] != '/') { |
| 218 | strcat(searchstr, "/"); |
| 219 | } |
| 220 | directory = opendir(searchstr); |
| 221 | if (!directory) { |
| 222 | return false; |
| 223 | } |
| 224 | |
| 225 | // TODO: make it use the filemask |
| 226 | while ((fileInfo = readdir(directory))) { |
| 227 | if (!((strcmp(fileInfo->d_name, ".") == 0) || |
| 228 | (strcmp(fileInfo->d_name, "..") == 0))) { |
| 229 | FilePath = searchstr; |
| 230 | FilePath += fileInfo->d_name; |
| 231 | |
| 232 | |
| 233 | stat(FilePath.c_str(), &statbuf); |
| 234 | |
| 235 | if (justDirs && S_ISDIR(statbuf.st_mode)) { |
| 236 | // we never do just dirs recrusively |
| 237 | list.push_back(FilePath); |
| 238 | } |
| 239 | else if (!justDirs) { |
| 240 | if (S_ISDIR(statbuf.st_mode) && bRecursive) { |
| 241 | LinuxAddFileStack(FilePath.c_str(), fileMask, bRecursive, list); |
| 242 | } |
| 243 | else if (match_mask(fileMask, fileInfo->d_name)) { |
| 244 | list.push_back(FilePath); |
| 245 | } |
| 246 | } |
| 247 | } |
| 248 | } |
| 249 | closedir(directory); |
| 250 | return true; |
| 251 | } |
| 252 | #endif |
| 253 | |
| 254 | // ensures all the delims are constant |
no test coverage detected