mirror of
https://github.com/odin-lang/Odin.git
synced 2026-06-06 18:54:12 +00:00
* Add files stat_linux and dir_linux to mirror the stat/dir_windows API * Add helper functions to os_linux that are used by the above
27 lines
570 B
Odin
27 lines
570 B
Odin
//+build linux, darwin, freebsd
|
|
package filepath
|
|
|
|
import "core:strings"
|
|
import "core:os"
|
|
|
|
SEPARATOR :: '/';
|
|
SEPARATOR_STRING :: `/`;
|
|
LIST_SEPARATOR :: ':';
|
|
|
|
abs :: proc(path: string, allocator := context.allocator) -> (string, bool) {
|
|
full_path, err := os.absolute_path_from_relative(path);
|
|
if err != os.ERROR_NONE {
|
|
return "", false;
|
|
}
|
|
return full_path, true;
|
|
}
|
|
|
|
join :: proc(elems: ..string, allocator := context.allocator) -> string {
|
|
s := strings.join(elems, SEPARATOR_STRING);
|
|
return s;
|
|
}
|
|
|
|
is_abs :: proc(path: string) -> bool {
|
|
return (path[0] == '/');
|
|
}
|