core/os: Add dir procedure

This commit is contained in:
juaum
2026-04-04 10:13:19 +02:00
parent a896fb2b4c
commit d06572c831

View File

@@ -383,6 +383,24 @@ base :: proc(path: string) -> string {
return file
}
/*
Gets the parent directory path from a path.
e.g.
'/home/foo/bar.tar.gz' -> '/home/foo'
'path/to/name.tar.gz' -> 'path/to'
Returns "." if the path is an empty string.
*/
dir :: proc(path: string) -> string {
if path == "" {
return "."
}
d, _ := split_path(path)
return d
}
/*
Gets the name of a file from a path.