7 if (modulePath ==
nullptr || searchedPath ==
nullptr) {
10 size_t modNameLen = strlen(modulePath);
11 size_t sysPathLen = strlen(searchedPath);
13 for (; i < modNameLen && i < sysPathLen; i++) {
14 char c1 = tolower(modulePath[i]);
15 char c2 = tolower(searchedPath[i]);
16 if (c1 ==
'/') c1 =
'\\';
21 if (i == sysPathLen) {
22 return modulePath + i;
29 size_t pos = std::string::npos;
31 const char to_escape =
'\\';
32 const std::string escaped =
"\\\\";
35 pos = path.find(to_escape, prev);
36 if (pos == std::string::npos)
break;
38 path.replace(pos, 1, escaped);
39 prev = pos + escaped.length();
41 }
while (pos < path.length() && prev < path.length());
49 if (!GetWindowsDirectoryA(buf,
MAX_PATH)) {
53 return std::string(buf);
58 char out_buf[MAX_PATH] = { 0 };
59 if (GetFullPathNameA(szPath, MAX_PATH, out_buf,
nullptr) == 0) {
67 DWORD dwAttrib = GetFileAttributes(szPath);
69 return (dwAttrib != INVALID_FILE_ATTRIBUTES &&
70 (dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
76 if (path.length() == 0) path = in_path;
84 pos = path.find_first_of(
"\\/", pos + 1);
85 if (CreateDirectoryA(path.substr(0, pos).c_str(), NULL) == FALSE) {
86 if (GetLastError() != ERROR_ALREADY_EXISTS) {
90 }
while (pos != std::string::npos);
96 const size_t prefix_len = prefix.length();
97 if (prefix_len == 0) {
104 size_t found_index = my_path.find(prefix);
105 if (found_index != std::string::npos
108 path.erase(found_index, prefix_len);
bool dir_exists(const char *path)
bool create_dir_recursively(const std::string &path)
char * get_subpath_ptr(char *modulePath, char *searchedPath)
std::string strip_prefix(std::string path, std::string prefix)
std::string to_lowercase(std::string)
std::string get_system_drive()
DWORD(__stdcall *_PssCaptureSnapshot)(HANDLE ProcessHandle
std::string escape_path_separators(std::string path)
std::string get_full_path(const char *szPath)