mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 06:38:47 +00:00
Remove core:encoding/ini dependency in user_posix.odin
This commit is contained in:
+12
-12
@@ -2,7 +2,6 @@
|
|||||||
package os2
|
package os2
|
||||||
|
|
||||||
import "base:runtime"
|
import "base:runtime"
|
||||||
import "core:encoding/ini"
|
|
||||||
import "core:strings"
|
import "core:strings"
|
||||||
|
|
||||||
_user_cache_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) {
|
_user_cache_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) {
|
||||||
@@ -157,18 +156,19 @@ _xdg_user_dirs_lookup :: proc(xdg_key: string, allocator: runtime.Allocator) ->
|
|||||||
user_dirs_path := concatenate({config_dir, "/user-dirs.dirs"}, temp_allocator) or_return
|
user_dirs_path := concatenate({config_dir, "/user-dirs.dirs"}, temp_allocator) or_return
|
||||||
content := read_entire_file(user_dirs_path, temp_allocator) or_return
|
content := read_entire_file(user_dirs_path, temp_allocator) or_return
|
||||||
|
|
||||||
it := ini.Iterator{
|
xdg_dirs := string(content)
|
||||||
section = "",
|
for line in strings.split_lines_iterator(&xdg_dirs) {
|
||||||
_src = string(content),
|
if len(line) > 0 && line[0] == '#' {
|
||||||
options = ini.Options{
|
continue
|
||||||
comment = "#",
|
}
|
||||||
key_lower_case = false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for k, v in ini.iterate(&it) {
|
equals := strings.index(line, "=")
|
||||||
if k == xdg_key {
|
if equals > -1 {
|
||||||
return replace_environment_placeholders(v, allocator), nil
|
if line[:equals] == xdg_key {
|
||||||
|
// Unquote to return a bare path string as we do on Windows
|
||||||
|
val := strings.trim(line[equals+1:], "\"")
|
||||||
|
return replace_environment_placeholders(val, allocator), nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user