-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.odin
More file actions
37 lines (28 loc) · 1.02 KB
/
Copy pathutil.odin
File metadata and controls
37 lines (28 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main
import "core:fmt"
import "core:strings"
import "core:os"
import "core:path/filepath"
join_path :: proc(elems: []string, allocator := context.allocator) -> string {
return filepath.join(elems, allocator) or_else panic("join_path allocation failed")
}
clean_path :: proc(path: string, allocator := context.allocator) -> string {
return filepath.clean(path, allocator) or_else panic("clean_path allocation failed")
}
remove_args :: proc(args: ^[dynamic]string, index, count: int) {
for _ in 0 ..< count {
ordered_remove(args, index)
}
}
persist_string :: proc(s: string, allocator := context.allocator) -> string {
return strings.clone(s, allocator) or_else panic("allocation failed")
}
persist_printf :: proc(format: string, args: ..any, allocator := context.allocator) -> string {
return persist_string(fmt.tprintf(format, ..args), allocator)
}
is_dir_entry :: proc(entry: os.File_Info) -> bool {
return entry.type == .Directory
}
is_file_entry :: proc(entry: os.File_Info) -> bool {
return entry.type == .Regular
}