Adapted utils_create_dir_recursively to general project style

This commit is contained in:
mkrsym1
2023-08-10 01:15:53 +03:00
parent e9d2130105
commit c80635fc71
3 changed files with 6 additions and 9 deletions

View File

@ -34,21 +34,18 @@ uint32_t utils_file_crc32c(const wchar_t *filePath) {
}
// https://stackoverflow.com/a/16719260
void utils_create_dir_recursively(const wchar_t *path) {
void utils_create_parent_dirs(const wchar_t *path) {
wchar_t dir[MAX_PATH];
ZeroMemory(dir, MAX_PATH * sizeof(wchar_t));
ZeroMemory(dir, sizeof(dir));
wchar_t *end = wcschr(path, L'\\');
const wchar_t *end = path - 1;
while(end != NULL)
{
while((end = wcschr(++end, L'\\')) != NULL) {
wcsncpy(dir, path, end - path + 1);
if (!utils_path_exists(dir) && !CreateDirectoryW(dir, NULL)) {
msg_err_w(L"Failed to create directory: %ls", dir);
}
end = wcschr(++end, L'\\');
}
}