Adapted utils_create_dir_recursively to general project style
This commit is contained in:
parent
e9d2130105
commit
c80635fc71
@ -7,7 +7,7 @@
|
||||
int utils_path_exists(const wchar_t *filePath);
|
||||
uint32_t utils_file_crc32c(const wchar_t *filePath);
|
||||
|
||||
void utils_create_dir_recursively(const wchar_t *path);
|
||||
void utils_create_parent_dirs(const wchar_t *path);
|
||||
|
||||
void utils_save_to_file(const wchar_t *filePath, const void *buf, size_t length);
|
||||
|
||||
|
@ -62,7 +62,7 @@ static void _run_tx(struct game_data *game, wchar_t *txFile) {
|
||||
void *table = core_perform_tx(game, &tableSize);
|
||||
|
||||
// Save to file
|
||||
utils_create_dir_recursively(txFile);
|
||||
utils_create_parent_dirs(txFile);
|
||||
utils_save_to_file(txFile, table, tableSize);
|
||||
|
||||
// Cleanup
|
||||
|
@ -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'\\');
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user