mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-06 06:38:20 +00:00
Merge pull request #6517 from juaumjuaumjuaum/master
core/os: Add dir procedure
This commit is contained in:
@@ -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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user