diff --git a/core/os/path.odin b/core/os/path.odin index 766adcaa9..0a0c8356a 100644 --- a/core/os/path.odin +++ b/core/os/path.odin @@ -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.