Mercurial > wgsdk
changeset 3:8df8af626dca
dirtools: sys/stat.h->windows.h
committer: GitHub <noreply@github.com>
author | Paper <37962225+mrpapersonic@users.noreply.github.com> |
---|---|
date | Sun, 07 Aug 2022 22:47:41 -0400 |
parents | 712c7fd6702a |
children | 59bf702b2b21 |
files | src/dirtools.c |
diffstat | 1 files changed, 6 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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 <stdio.h> #include <stdlib.h> #include <string.h> -#include <sys/stat.h> #ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN #endif #include <windows.h> #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 */