diff --git a/include/compat.h b/include/compat.h index bd0e70e..f57ccb8 100644 --- a/include/compat.h +++ b/include/compat.h @@ -27,7 +27,6 @@ #include #define hs_isatty(x) false -#define hs_mkdir(path) CreateDirectoryA((path), NULL) static inline wchar_t * @@ -76,14 +75,22 @@ hs_fopen( } static inline -char const * -hs_basename( +bool +hs_mkdir( char const *path ) { - char const *base; + wchar_t *wpath; + bool out; - base = strrchr(path, '\\'); - return (base ? base + 1 : path); + wpath = hs_convert_to_wchar(path); + if (!wpath) { + return (false); + } + + out = CreateDirectoryW(wpath, NULL); + + free(wpath); + return out; } static inline @@ -105,6 +112,17 @@ hs_fexists( return (out); } +static inline +char const * +hs_basename( + char const *path +) { + char const *base; + + base = strrchr(path, '\\'); + return (base ? base + 1 : path); +} + static inline char * hs_fmtime( @@ -221,7 +239,7 @@ hs_fmtime( return (NULL); } - out = malloc(sizeof(char) * 128); + out = (char *)malloc(sizeof(char) * 128); hs_assert(out); tm = localtime(&stbuf.st_mtime);