From d06572c831b4b301a79ee535e89857dfeefac6d5 Mon Sep 17 00:00:00 2001 From: juaum Date: Sat, 4 Apr 2026 10:13:19 +0200 Subject: [PATCH] core/os: Add dir procedure --- core/os/path.odin | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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.