added path_getUserDir, dir_createParent
This commit is contained in:
@@ -39,6 +39,8 @@ str path_dirname(str path);
|
||||
/// @return pointer to a segment of path.data or path itself if no path_sep has been found
|
||||
str path_basename(str path, bool remove_ext);
|
||||
|
||||
/// @return heap-allocated string
|
||||
Result(char*) path_getUserDir();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// FILE //
|
||||
@@ -145,8 +147,15 @@ Result(void) file_readWholeText(FILE* f, str* out_str);
|
||||
// DIRECTORY //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// @return true if directory exists or `path` is null or empty or '.' or './'
|
||||
bool dir_exists(cstr path);
|
||||
|
||||
/// @brief creates directories specified in path recursively
|
||||
/// EXAMPLE: dir_createParent("a/b/c") -> creates "a", "a/b", "a/b/c"
|
||||
/// @return false if directory was present already, true if it has been created
|
||||
Result(bool) dir_create(cstr path);
|
||||
|
||||
/// @brief creates directories except the last part of path
|
||||
/// EXAMPLE: dir_createParent("a/b/c") -> creates "a", "a/b"
|
||||
/// @return false if directory was present already, true if it has been created
|
||||
Result(bool) dir_createParent(cstr path);
|
||||
|
||||
@@ -16,10 +16,10 @@ typedef struct str {
|
||||
/*
|
||||
USAGE:
|
||||
str s = STR("something");
|
||||
printf(FMT_str"\n", str_expand(s));
|
||||
printf(FMT_str"\n", str_unwrap(s));
|
||||
*/
|
||||
#define FMT_str "%.*s"
|
||||
#define str_expand(S) (S).len, (S).data
|
||||
#define str_unwrap(S) (S).len, (S).data
|
||||
|
||||
/// creates str from a string literal
|
||||
#define STR(LITERAL) str_construct(LITERAL, ARRAY_LEN(LITERAL) - 1, true)
|
||||
@@ -59,7 +59,7 @@ static inline str Array_u8_castTo_str(Array(u8) a, bool isZeroTerminated) {
|
||||
|
||||
static const str str_null = str_construct(NULL, 0, 0);
|
||||
|
||||
/// copies src content to new string and adds \0 at the end
|
||||
/// copy str data to new str and add \0 at the end
|
||||
str str_copy(const str self);
|
||||
|
||||
/// compares two strings, NullPtr-friendly
|
||||
|
||||
Reference in New Issue
Block a user