# HG changeset patch # User Paper <37962225+mrpapersonic@users.noreply.github.com> # Date 1659926861 14400 # Node ID 8df8af626dcad1d0cde13d0c1eed6fa0309501a8 # Parent 712c7fd6702a5c3483eab4056ce46a3bc912b4d2 dirtools: sys/stat.h->windows.h committer: GitHub diff -r 712c7fd6702a -r 8df8af626dca src/dirtools.c --- a/src/dirtools.c Sun Aug 07 10:41:55 2022 -0400 +++ b/src/dirtools.c Sun Aug 07 22:47:41 2022 -0400 @@ -1,20 +1,23 @@ #include #include #include -#include #ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN #endif #include #include "dirtools.h" +int dirtools_directory_exists(char* path) { + DWORD attrib = GetFileAttributesA(path); + return (attrib != INVALID_FILE_ATTRIBUTES && (attrib & FILE_ATTRIBUTE_DIRECTORY)); +} + int dirtools_create_directory(char* path) { - struct stat st = {0}; char* alltoks = calloc(strlen(path), sizeof(char)), *tok; for (tok = strtok(path, "\\"); tok != NULL; tok = strtok(NULL, "\\")) { strcat(alltoks, tok); - if (stat(alltoks, &st) == -1) { + if (dirtools_directory_exists(path)) { if (!CreateDirectoryA(alltoks, NULL)) { if (GetLastError() == ERROR_PATH_NOT_FOUND) { /* ERROR_PATH_NOT_FOUND should NOT happen here */