Mercurial > wgsdk
comparison src/dirtools.c @ 4:59bf702b2b21
*: stylistic changes
| author | Paper <mrpapersonic@gmail.com> |
|---|---|
| date | Sun, 14 Aug 2022 13:17:32 -0400 |
| parents | 8df8af626dca |
| children | be4835547dd0 |
comparison
equal
deleted
inserted
replaced
| 3:8df8af626dca | 4:59bf702b2b21 |
|---|---|
| 11 DWORD attrib = GetFileAttributesA(path); | 11 DWORD attrib = GetFileAttributesA(path); |
| 12 return (attrib != INVALID_FILE_ATTRIBUTES && (attrib & FILE_ATTRIBUTE_DIRECTORY)); | 12 return (attrib != INVALID_FILE_ATTRIBUTES && (attrib & FILE_ATTRIBUTE_DIRECTORY)); |
| 13 } | 13 } |
| 14 | 14 |
| 15 int dirtools_create_directory(char* path) { | 15 int dirtools_create_directory(char* path) { |
| 16 char* alltoks = calloc(strlen(path), sizeof(char)), *tok; | 16 char* alltoks = calloc(strlen(path)+2, sizeof(char)), *tok; |
| 17 | 17 |
| 18 for (tok = strtok(path, "\\"); tok != NULL; tok = strtok(NULL, "\\")) { | 18 for (tok = strtok(path, "\\"); tok != NULL; tok = strtok(NULL, "\\")) { |
| 19 strcat(alltoks, tok); | 19 strcat(alltoks, tok); |
| 20 strcat(alltoks, "\\"); | |
| 20 if (dirtools_directory_exists(path)) { | 21 if (dirtools_directory_exists(path)) { |
| 21 if (!CreateDirectoryA(alltoks, NULL)) { | 22 if (!CreateDirectoryA(alltoks, NULL)) { |
| 22 if (GetLastError() == ERROR_PATH_NOT_FOUND) { | 23 if (GetLastError() == ERROR_PATH_NOT_FOUND) { |
| 23 /* ERROR_PATH_NOT_FOUND should NOT happen here */ | 24 /* ERROR_PATH_NOT_FOUND should NOT happen here */ |
| 24 return 1; | 25 return 1; |
