mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-10 21:31:37 -07:00
* Add some procedures to path_unix to mirror the path_windows API
* 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
This commit is contained in:
@@ -218,6 +218,7 @@ get_escape :: proc(chunk: string) -> (r: rune, next_chunk: string, err: Match_Er
|
||||
//
|
||||
// glob ignores file system errors
|
||||
//
|
||||
|
||||
glob :: proc(pattern: string, allocator := context.allocator) -> (matches: []string, err: Match_Error) {
|
||||
if !has_meta(pattern) {
|
||||
// TODO(bill): os.lstat on here to check for error
|
||||
@@ -272,14 +273,15 @@ _glob :: proc(dir, pattern: string, matches: ^[dynamic]string) -> (m: [dynamic]s
|
||||
}
|
||||
defer os.close(d);
|
||||
|
||||
file_info, ferr := os.fstat(d);
|
||||
if ferr != 0 {
|
||||
os.file_info_delete(file_info);
|
||||
return;
|
||||
}
|
||||
if !file_info.is_dir {
|
||||
os.file_info_delete(file_info);
|
||||
return;
|
||||
{
|
||||
file_info, ferr := os.fstat(d);
|
||||
defer os.file_info_delete(file_info);
|
||||
if ferr != 0 {
|
||||
return;
|
||||
}
|
||||
if !file_info.is_dir {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,26 @@
|
||||
//+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] == '/');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user