path_basename
This commit is contained in:
parent
ce44509d04
commit
2a9214fb79
@ -70,3 +70,15 @@ char* path_parentDir(char* dir){
|
|||||||
}
|
}
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char* path_basename(char* path, bool with_extension){
|
||||||
|
i32 nameIndex=cptr_lastIndexOfChar(path, path_sep)+1;
|
||||||
|
string rezult=string_fromCptr(path+nameIndex);
|
||||||
|
if(!with_extension){
|
||||||
|
i32 extIndex=cptr_lastIndexOfChar(rezult.ptr, '.');
|
||||||
|
if(extIndex!=0 && extIndex!=-1)
|
||||||
|
rezult.length=extIndex;
|
||||||
|
}
|
||||||
|
return string_extract(rezult);
|
||||||
|
}
|
||||||
|
|||||||
@ -31,7 +31,11 @@ char* path_fixSeparators(const char* path);
|
|||||||
/// @return Maybe<void>
|
/// @return Maybe<void>
|
||||||
Maybe path_throwIfEscapes(const char* path);
|
Maybe path_throwIfEscapes(const char* path);
|
||||||
|
|
||||||
char* path_parentDir(char* dir);
|
///@return path of parent dir
|
||||||
|
char* path_parentDir(char* path);
|
||||||
|
|
||||||
|
///@return file name
|
||||||
|
char* path_basename(char* path, bool with_extension);
|
||||||
|
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user