filesystem rework

This commit is contained in:
2023-02-09 01:42:10 +06:00
parent 29a5b22286
commit 835bc5e834
10 changed files with 177 additions and 12 deletions

View File

@@ -53,3 +53,22 @@ Maybe path_throwIfEscapes(char* path){
safethrow(cptr_concat("path <",path,"> uses <..>, that's not allowed"),);
return MaybeNull;
}
char* path_parentDir(char* dir){
throw(ERR_NOTIMPLEMENTED);
char* copy=cptr_copy(dir);
uint32 length=cptr_length(copy);
int i=cptr_lastIndexOfChar(copy,path_sep);
if(i==length-1){
copy[length-1]=0;
i=cptr_lastIndexOfChar(copy,path_sep);
}
if(i==-1){
free(copy);
copy=malloc(3);
copy[0]='.';
copy[1]=path_sep;
copy[2]=0;
}
return copy;
}