added path_fix_separators
This commit is contained in:
@@ -31,6 +31,9 @@
|
||||
#define path_notseps "\\"
|
||||
#endif
|
||||
|
||||
// @brief replaces path_notsep with path_sep
|
||||
void path_fix_separators(str* path);
|
||||
|
||||
/// @brief removes part of path after path_sep (including path_sep)
|
||||
/// @return pointer to a segment of path.data or "." if no path_sep has been found
|
||||
str path_dirname(str path);
|
||||
|
||||
@@ -90,6 +90,10 @@ str hex_to_str(Array(u8) buf, bool uppercase);
|
||||
void str_trim(str* line, bool set_zero_at_end);
|
||||
|
||||
|
||||
/// replaces all occurences of `fragment` in `s` with `replacement`
|
||||
void str_replaceChar(str* s, char fragment, char replacement);
|
||||
|
||||
|
||||
///@return s[0..n]
|
||||
static inline str str_sliceBefore(str s, u32 n){
|
||||
return str_construct(s.data, n, false);
|
||||
|
||||
@@ -35,7 +35,7 @@ OBJDIR="obj"
|
||||
OUTDIR="bin"
|
||||
STATIC_LIB_FILE="$PROJECT.a"
|
||||
|
||||
INCLUDE="-I./include"
|
||||
INCLUDE="-Iinclude"
|
||||
|
||||
# OS-specific options
|
||||
case "$OS" in
|
||||
|
||||
@@ -6,6 +6,10 @@
|
||||
#else
|
||||
#endif
|
||||
|
||||
void path_fix_separators(str* path){
|
||||
str_replaceChar(path, path_notsep, path_sep);
|
||||
}
|
||||
|
||||
str path_dirname(str path){
|
||||
if(path.len == 0)
|
||||
return path;
|
||||
|
||||
@@ -175,3 +175,10 @@ void str_trim(str* line, bool set_zero_at_end){
|
||||
line->isZeroTerminated = true;
|
||||
}
|
||||
}
|
||||
|
||||
void str_replaceChar(str* s, char fragment, char replacement){
|
||||
for(u32 i = 0; i < s->len; i++){
|
||||
if(s->data[i] == fragment)
|
||||
s->data[i] = replacement;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user