New list dir api

This commit is contained in:
Krzosa Karol
2024-01-13 14:49:38 +01:00
parent 2cb4160497
commit 3408f3a1ff
10 changed files with 138 additions and 182 deletions

View File

@@ -111,6 +111,15 @@ S8_API S8_String S8_Copy(S8_Allocator allocator, S8_String string) {
return result;
}
S8_API S8_String S8_CopyChar(S8_Allocator allocator, char *s) {
int64_t len = S8_Length(s);
char *copy = (char *)S8_ALLOCATE(allocator, sizeof(char) * (len + 1));
S8_MemoryCopy(copy, s, len);
copy[len] = 0;
S8_String result = S8_Make(copy, len);
return result;
}
S8_API void S8_NormalizePath(S8_String s) {
for (int64_t i = 0; i < s.len; i++) {
if (s.str[i] == '\\')
@@ -169,7 +178,7 @@ S8_API S8_String S8_GetPrefix(S8_String string, int64_t len) {
return result;
}
S8_API S8_String S8_GetNameNoExtension(S8_String s) {
S8_API S8_String S8_GetNameNoExt(S8_String s) {
return S8_SkipToLastSlash(S8_ChopLastPeriod(s));
}

View File

@@ -32,19 +32,6 @@ struct S8_String {
int64_t len;
};
// #ifdef __cplusplus
// struct String : S8_String {
// String() = default;
// String(char *s) : S8_String{s, S8_Length(s)} {}
// String(char *s, int64_t l) : S8_String{s, l} {}
// String(const char *s) : S8_String{(char *)s, S8_Length((char *)s)} {}
// String(const char *s, int64_t l) : S8_String{(char *)s, l} {}
// String(S8_String s) : S8_String{s.str, s.len} {}
// // @todo add unicode iterator
// };
// #endif
struct S8_Node {
S8_Node *next;
S8_String string;