From 02c72c21fe8a31837d3156a518b6acea676b3997 Mon Sep 17 00:00:00 2001 From: Madeorsk Date: Wed, 14 Jun 2023 17:52:31 +0200 Subject: [PATCH] Add Windows support for ksrfiles. --- src/files.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/files.c b/src/files.c index 6689118..5562c9c 100644 --- a/src/files.c +++ b/src/files.c @@ -2,14 +2,18 @@ #include #include -#include #include #include #include #include +#ifndef _WIN32 +#include +#endif + char* path_exp_simple(const char* path) { +#ifndef _WIN32 // expanding the path. wordexp_t exp; wordexp(path, &exp, 0); @@ -18,8 +22,10 @@ char* path_exp_simple(const char* path) wordfree(&exp); // freeing the path expansion. return expanded_path; // returning the first expanded path. +#else + return strdup(path); +#endif } - int mkpath(const char *path, const mode_t mode) { // getting the current directory path to create. @@ -37,7 +43,11 @@ int mkpath(const char *path, const mode_t mode) } // creating the current directory. - res = mkdir(dirpath, mode); + res = mkdir(dirpath + #ifndef _WIN32 + , mode + #endif + ); if (errno == EEXIST) // the directory exists, everything have been created correctly. res = 0;