Merge pull request #6517 from juaumjuaumjuaum/master

core/os: Add dir procedure
This commit is contained in:
Jeroen van Rijn
2026-04-04 12:09:57 +02:00
committed by GitHub

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.