diff --git a/src/Filesystem/path.c b/src/Filesystem/path.c index 6b52991..0a8757b 100644 --- a/src/Filesystem/path.c +++ b/src/Filesystem/path.c @@ -1,13 +1,13 @@ #include "filesystem.h" -char* __path_concat(uint16 n, char* prev_part, ...){ +char* __path_concat(uint16 n, ...){ char** parts=(char**)malloc(n*sizeof(char*)); uint32* lengths=malloc(n*sizeof(uint32)); uint32 totalLength=0; // reading args from va_list va_list vl; - va_start(vl, prev_part); + va_start(vl, n); for(uint16 i=0; i uses <..>, that's not allowed"),); + return MaybeNull; +} diff --git a/src/Filesystem/path.h b/src/Filesystem/path.h index 1b9ec52..7c3b049 100644 --- a/src/Filesystem/path.h +++ b/src/Filesystem/path.h @@ -8,12 +8,28 @@ extern "C" { #if defined(_WIN32) || defined (_WIN64) static const char path_sep='\\'; +static const char path_notSep='/'; #else static const char path_sep='/'; +static const char path_notSep='\\'; #endif -char* __path_concat(uint16 n, char* path_start, ...); -#define path_concat(PATH_PARTS) __path_concat(count_args(PATH_PARTS), PATH_PARTS) +char* __path_concat(uint16 n, ...); +/// @brief merges path parts together and places between them +/// @return new cstr +#define path_concat(PATH_PARTS...) __path_concat(count_args(PATH_PARTS), PATH_PARTS) + +/// @brief fixes path separators +/// @param cstr where can be +/// @return new cstr with correct separators +char* path_fixSeparators(char* path); + +#define path_resolve(PATH_PARTS...) path_fixSeparators(path_concat(PATH_PARTS)) + +/// @brief calls safethrow() if finds escape sequense in path +/// @param path cstr where can be <..> +/// @return Maybe +Maybe path_throwIfEscapes(char* path); #if __cplusplus }