mirror of
https://github.com/odin-lang/Odin.git
synced 2026-05-25 13:18:14 +00:00
Merge pull request #6528 from Faker-09/filepath_dir_empty_path_fix
filepath.dir empty path fix
This commit is contained in:
@@ -245,12 +245,12 @@ rel :: proc(base_path, target_path: string, allocator := context.allocator) -> (
|
||||
}
|
||||
|
||||
/*
|
||||
Returns all but the last element path, usually the path's directory. Once the final element has been removed,
|
||||
`dir` calls `clean` on the path and trailing separators are removed. If the path consists purely of separators,
|
||||
then `"."` is returned.
|
||||
Returns all but the last path element, usually the path's directory. Once the final element has been removed,
|
||||
`dir` calls `clean` on the path and trailing separators are removed. If the path is empty or consists purely
|
||||
of separators, then `"."` is returned.
|
||||
*/
|
||||
dir :: proc(path: string, allocator := context.allocator) -> string {
|
||||
i := len(path) - 1
|
||||
i := len(path) > 0 ? len(path) - 1 : 0
|
||||
for i > 0 && !is_separator(path[i]) {
|
||||
i -= 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user