| 39 | } |
| 40 | |
| 41 | size_t FileCountInDirectory(const std::string &path) |
| 42 | { |
| 43 | int counter = 0; |
| 44 | WIN32_FIND_DATA ffd; |
| 45 | HANDLE hFind = INVALID_HANDLE_VALUE; |
| 46 | std::string dirPath = path; |
| 47 | if (dirPath.at(dirPath.length() - 1) != '\\' && |
| 48 | dirPath.at(dirPath.length() - 1) != '/') |
| 49 | { |
| 50 | dirPath.append("\\"); |
| 51 | } |
| 52 | dirPath.append("*"); |
| 53 | |
| 54 | // Start iterating over the files in the path directory. |
| 55 | hFind = FindFirstFileA(dirPath.c_str(), &ffd); |
| 56 | if (hFind != INVALID_HANDLE_VALUE) |
| 57 | { |
| 58 | do // Managed to locate and create an handle to that folder. |
| 59 | { |
| 60 | counter++; |
| 61 | } while (FindNextFileA(hFind, &ffd) == TRUE); |
| 62 | FindClose(hFind); |
| 63 | } |
| 64 | else |
| 65 | { |
| 66 | LOG_ERR("Failed to find path: %s", dirPath.c_str()); |
| 67 | } |
| 68 | |
| 69 | return counter; |
| 70 | } |
| 71 | |
| 72 | bool splitFileName(std::string const &fileName, |
| 73 | std::string *name, |
no test coverage detected