|
1 | 1 | package filepath |
2 | 2 |
|
3 | | -import "core:strings" |
4 | | -import "base:runtime" |
5 | | -import "core:os" |
6 | | -import win32 "core:sys/windows" |
| 3 | +import "core:strings" |
| 4 | +import "base:runtime" |
| 5 | +import os "core:os/os2" |
7 | 6 |
|
8 | 7 | SEPARATOR :: '\\' |
9 | 8 | SEPARATOR_STRING :: `\` |
@@ -33,50 +32,12 @@ is_UNC :: proc(path: string) -> bool { |
33 | 32 | } |
34 | 33 |
|
35 | 34 | is_abs :: proc(path: string) -> bool { |
36 | | - if is_reserved_name(path) { |
37 | | - return true |
38 | | - } |
39 | | - l := volume_name_len(path) |
40 | | - if l == 0 { |
41 | | - return false |
42 | | - } |
43 | | - |
44 | | - path := path |
45 | | - path = path[l:] |
46 | | - if path == "" { |
47 | | - return false |
48 | | - } |
49 | | - return is_slash(path[0]) |
50 | | -} |
51 | | - |
52 | | -@(private) |
53 | | -temp_full_path :: proc(name: string) -> (path: string, err: os.Error) { |
54 | | - ta := context.temp_allocator |
55 | | - |
56 | | - name := name |
57 | | - if name == "" { |
58 | | - name = "." |
59 | | - } |
60 | | - |
61 | | - p := win32.utf8_to_utf16(name, ta) |
62 | | - n := win32.GetFullPathNameW(cstring16(raw_data(p)), 0, nil, nil) |
63 | | - if n == 0 { |
64 | | - return "", os.get_last_error() |
65 | | - } |
66 | | - |
67 | | - buf := make([]u16, n, ta) |
68 | | - n = win32.GetFullPathNameW(cstring16(raw_data(p)), u32(len(buf)), cstring16(raw_data(buf)), nil) |
69 | | - if n == 0 { |
70 | | - delete(buf) |
71 | | - return "", os.get_last_error() |
72 | | - } |
73 | | - |
74 | | - return win32.utf16_to_utf8(buf[:n], ta) |
| 35 | + return os.is_absolute_path(path) |
75 | 36 | } |
76 | 37 |
|
77 | 38 | abs :: proc(path: string, allocator := context.allocator) -> (string, bool) { |
78 | 39 | runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = allocator == context.temp_allocator) |
79 | | - full_path, err := temp_full_path(path) |
| 40 | + full_path, err := os.get_absolute_path(path, context.temp_allocator) |
80 | 41 | if err != nil { |
81 | 42 | return "", false |
82 | 43 | } |
|
0 commit comments