mirror of
https://github.com/odin-lang/Odin.git
synced 2026-05-05 20:44:40 +00:00
Update sync2 to just use atomic intrinsics rather than the parapoly wrappers
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
package os
|
||||
|
||||
import "core:time"
|
||||
import "core:path"
|
||||
|
||||
/*
|
||||
For reference
|
||||
@@ -71,6 +70,36 @@ _fill_file_info_from_stat :: proc(fi: ^File_Info, s: OS_Stat) {
|
||||
fi.access_time = _make_time_from_unix_file_time(s.last_access);
|
||||
}
|
||||
|
||||
|
||||
@private
|
||||
path_base :: proc(path: string) -> string {
|
||||
is_separator :: proc(c: byte) -> bool {
|
||||
return c == '/';
|
||||
}
|
||||
|
||||
if path == "" {
|
||||
return ".";
|
||||
}
|
||||
|
||||
path := path;
|
||||
for len(path) > 0 && is_separator(path[len(path)-1]) {
|
||||
path = path[:len(path)-1];
|
||||
}
|
||||
|
||||
i := len(path)-1;
|
||||
for i >= 0 && !is_separator(path[i]) {
|
||||
i -= 1;
|
||||
}
|
||||
if i >= 0 {
|
||||
path = path[i+1:];
|
||||
}
|
||||
if path == "" {
|
||||
return "/";
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
lstat :: proc(name: string, allocator := context.allocator) -> (fi: File_Info, err: Errno) {
|
||||
|
||||
context.allocator = allocator;
|
||||
@@ -85,7 +114,7 @@ lstat :: proc(name: string, allocator := context.allocator) -> (fi: File_Info, e
|
||||
if err != ERROR_NONE {
|
||||
return;
|
||||
}
|
||||
fi.name = path.base(fi.fullpath);
|
||||
fi.name = path_base(fi.fullpath);
|
||||
return fi, ERROR_NONE;
|
||||
}
|
||||
|
||||
@@ -103,7 +132,7 @@ stat :: proc(name: string, allocator := context.allocator) -> (fi: File_Info, er
|
||||
if err != ERROR_NONE {
|
||||
return;
|
||||
}
|
||||
fi.name = path.base(fi.fullpath);
|
||||
fi.name = path_base(fi.fullpath);
|
||||
return fi, ERROR_NONE;
|
||||
}
|
||||
|
||||
@@ -121,6 +150,6 @@ fstat :: proc(fd: Handle, allocator := context.allocator) -> (fi: File_Info, err
|
||||
if err != ERROR_NONE {
|
||||
return;
|
||||
}
|
||||
fi.name = path.base(fi.fullpath);
|
||||
fi.name = path_base(fi.fullpath);
|
||||
return fi, ERROR_NONE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user