diff options
Diffstat (limited to 'tests/unity/unity_support.c')
-rw-r--r-- | tests/unity/unity_support.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/tests/unity/unity_support.c b/tests/unity/unity_support.c index e5e4c3a22..c045d6ddf 100644 --- a/tests/unity/unity_support.c +++ b/tests/unity/unity_support.c @@ -13,16 +13,23 @@ *********************/ #if LV_BUILD_TEST #include "../lvgl.h" -#include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <stdarg.h> -#include <sys/stat.h> +#include <errno.h> #include "unity.h" #define PNG_DEBUG 3 #include <png.h> +#ifdef _WIN32 +#include <direct.h> +#define mkdir(pathname, mode) _mkdir(pathname) +#define strtok_r strtok_s +#else +#include <sys/stat.h> +#endif + /********************* * DEFINES *********************/ @@ -429,21 +436,20 @@ static void create_folders_if_needed(const char * path) char * token = strtok_r(pathCopy, "/", &ptr); char current_path[1024] = {'\0'}; // Adjust the size as needed - struct stat st; while(token && ptr && *ptr != '\0') { strcat(current_path, token); strcat(current_path, "/"); - if(stat(current_path, &st) != 0) { - // Folder doesn't exist, create it - if(mkdir(current_path, 0777) != 0) { - perror("Error creating folder"); - free(pathCopy); - exit(EXIT_FAILURE); - } + int mkdir_retval = mkdir(current_path, 0777); + if (mkdir_retval == 0) { printf("Created folder: %s\n", current_path); } + else if (errno != EEXIST) { + perror("Error creating folder"); + free(pathCopy); + exit(EXIT_FAILURE); + } token = strtok_r(NULL, "/", &ptr); } |