Clean up allocator stuff into allocators.odin

This commit is contained in:
gingerBill
2024-05-14 17:10:53 +01:00
parent e05315831f
commit ecd7846ec3
8 changed files with 75 additions and 76 deletions
+7 -7
View File
@@ -23,7 +23,7 @@ _mkdir_all :: proc(path: string, perm: File_Mode) -> Error {
fix_root_directory :: proc(p: string) -> (s: string, allocated: bool, err: runtime.Allocator_Error) {
if len(p) == len(`\\?\c:`) {
if is_path_separator(p[0]) && is_path_separator(p[1]) && p[2] == '?' && is_path_separator(p[3]) && p[5] == ':' {
s = strings.concatenate({p, `\`}, _file_allocator()) or_return
s = strings.concatenate({p, `\`}, file_allocator()) or_return
allocated = true
return
}
@@ -31,9 +31,9 @@ _mkdir_all :: proc(path: string, perm: File_Mode) -> Error {
return p, false, nil
}
_TEMP_ALLOCATOR_GUARD()
TEMP_ALLOCATOR_GUARD()
dir, err := stat(path, _temp_allocator())
dir, err := stat(path, temp_allocator())
if err == nil {
if dir.is_directory {
return nil
@@ -54,14 +54,14 @@ _mkdir_all :: proc(path: string, perm: File_Mode) -> Error {
if j > 1 {
new_path, allocated := fix_root_directory(path[:j-1]) or_return
defer if allocated {
delete(new_path, _file_allocator())
delete(new_path, file_allocator())
}
mkdir_all(new_path, perm) or_return
}
err = mkdir(path, perm)
if err != nil {
dir1, err1 := lstat(path, _temp_allocator())
dir1, err1 := lstat(path, temp_allocator())
if err1 == nil && dir1.is_directory {
return nil
}
@@ -127,10 +127,10 @@ _fix_long_path_internal :: proc(path: string) -> string {
return path
}
_TEMP_ALLOCATOR_GUARD()
TEMP_ALLOCATOR_GUARD()
PREFIX :: `\\?`
path_buf := make([]byte, len(PREFIX)+len(path)+1, _temp_allocator())
path_buf := make([]byte, len(PREFIX)+len(path)+1, temp_allocator())
copy(path_buf, PREFIX)
n := len(path)
r, w := 0, len(PREFIX)