aboutsummaryrefslogtreecommitdiff
path: root/core/path/filepath
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2026-02-08 12:51:24 +0100
committerJeroen van Rijn <Kelimion@users.noreply.github.com>2026-02-08 12:51:24 +0100
commitaf8bc8bbfc8939234242690bc74c1ffe075a15df (patch)
treee36dcf660ee5ab7dd6851eeb9fe6ffc4dae0f306 /core/path/filepath
parentaf57035fd65cda96b7ec17e965184a922fdf6e82 (diff)
More conflicts during rebase
Diffstat (limited to 'core/path/filepath')
-rw-r--r--core/path/filepath/match.odin25
-rw-r--r--core/path/filepath/path_windows.odin52
-rw-r--r--core/path/filepath/walk.odin8
3 files changed, 19 insertions, 66 deletions
diff --git a/core/path/filepath/match.odin b/core/path/filepath/match.odin
index 3eaa7c6fe..e474085ed 100644
--- a/core/path/filepath/match.odin
+++ b/core/path/filepath/match.odin
@@ -2,10 +2,10 @@
#+build !js
package filepath
-import "core:os"
-import "core:slice"
-import "core:strings"
-import "core:unicode/utf8"
+import os "core:os/os2"
+import "core:slice"
+import "core:strings"
+import "core:unicode/utf8"
Match_Error :: enum {
None,
@@ -286,28 +286,23 @@ _glob :: proc(dir, pattern: string, matches: ^[dynamic]string, allocator := cont
defer os.close(d)
{
- file_info, ferr := os.fstat(d)
- defer os.file_info_delete(file_info)
+ file_info, ferr := os.fstat(d, allocator)
+ defer os.file_info_delete(file_info, allocator)
if ferr != nil {
return
}
- if !file_info.is_dir {
+ if file_info.type != .Directory {
return
}
}
- fis, _ := os.read_dir(d, -1)
+ fis, _ := os.read_dir(d, -1, allocator)
slice.sort_by(fis, proc(a, b: os.File_Info) -> bool {
return a.name < b.name
})
- defer {
- for fi in fis {
- os.file_info_delete(fi)
- }
- delete(fis)
- }
+ defer os.file_info_slice_delete(fis, allocator)
for fi in fis {
n := fi.name
@@ -359,4 +354,4 @@ clean_glob_path_windows :: proc(path: string, temp_buf: []byte) -> (prefix_len:
vol_len = len(path) -1
}
return vol_len, path[:len(path)-1]
-}
+} \ No newline at end of file
diff --git a/core/path/filepath/path_windows.odin b/core/path/filepath/path_windows.odin
index d7549a42c..862649532 100644
--- a/core/path/filepath/path_windows.odin
+++ b/core/path/filepath/path_windows.odin
@@ -1,9 +1,8 @@
package filepath
-import "core:strings"
-import "base:runtime"
-import "core:os"
-import win32 "core:sys/windows"
+import "core:strings"
+import "base:runtime"
+import os "core:os/os2"
SEPARATOR :: '\\'
SEPARATOR_STRING :: `\`
@@ -33,53 +32,12 @@ is_UNC :: proc(path: string) -> bool {
}
is_abs :: proc(path: string) -> bool {
- if is_reserved_name(path) {
- return true
- }
- if len(path) > 0 && is_slash(path[0]) {
- return true
- }
- l := volume_name_len(path)
- if l == 0 {
- return false
- }
-
- path := path
- path = path[l:]
- if path == "" {
- return false
- }
- return is_slash(path[0])
-}
-
-@(private)
-temp_full_path :: proc(name: string) -> (path: string, err: os.Error) {
- ta := context.temp_allocator
-
- name := name
- if name == "" {
- name = "."
- }
-
- p := win32.utf8_to_utf16(name, ta)
- n := win32.GetFullPathNameW(cstring16(raw_data(p)), 0, nil, nil)
- if n == 0 {
- return "", os.get_last_error()
- }
-
- buf := make([]u16, n, ta)
- n = win32.GetFullPathNameW(cstring16(raw_data(p)), u32(len(buf)), cstring16(raw_data(buf)), nil)
- if n == 0 {
- delete(buf)
- return "", os.get_last_error()
- }
-
- return win32.utf16_to_utf8(buf[:n], ta)
+ return os.is_absolute_path(path)
}
abs :: proc(path: string, allocator := context.allocator) -> (string, bool) {
runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = allocator == context.temp_allocator)
- full_path, err := temp_full_path(path)
+ full_path, err := os.get_absolute_path(path, context.temp_allocator)
if err != nil {
return "", false
}
diff --git a/core/path/filepath/walk.odin b/core/path/filepath/walk.odin
index 05d67daf0..845ba06a0 100644
--- a/core/path/filepath/walk.odin
+++ b/core/path/filepath/walk.odin
@@ -2,8 +2,8 @@
#+build !js
package filepath
-import "core:os"
-import "core:slice"
+import os "core:os/os2"
+import "core:slice"
// Walk_Proc is the type of the procedure called for each file or directory visited by 'walk'
// The 'path' parameter contains the parameter to walk as a prefix (this is the same as info.fullpath except on 'root')
@@ -40,7 +40,7 @@ walk :: proc(root: string, walk_proc: Walk_Proc, user_data: rawptr) -> os.Error
@(private)
_walk :: proc(info: os.File_Info, walk_proc: Walk_Proc, user_data: rawptr) -> (err: os.Error, skip_dir: bool) {
- if !info.is_dir {
+ if info.type != .Directory {
if info.fullpath == "" && info.name == "" {
// ignore empty things
return
@@ -62,7 +62,7 @@ _walk :: proc(info: os.File_Info, walk_proc: Walk_Proc, user_data: rawptr) -> (e
for fi in fis {
err, skip_dir = _walk(fi, walk_proc, user_data)
if err != nil || skip_dir {
- if !fi.is_dir || !skip_dir {
+ if fi.type != .Directory || !skip_dir {
return
}
}