mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-29 10:50:05 +00:00
add _chtimes
This commit is contained in:
@@ -27,6 +27,8 @@ _O_SYNC :: 0o4010000
|
|||||||
_O_CLOEXEC :: 0o2000000
|
_O_CLOEXEC :: 0o2000000
|
||||||
_O_PATH :: 0o10000000
|
_O_PATH :: 0o10000000
|
||||||
|
|
||||||
|
_AT_FDCWD :: -100
|
||||||
|
|
||||||
_open :: proc(name: string, flags: File_Flags, perm: File_Mode) -> (Handle, Error) {
|
_open :: proc(name: string, flags: File_Flags, perm: File_Mode) -> (Handle, Error) {
|
||||||
cstr := strings.clone_to_cstring(name, context.temp_allocator)
|
cstr := strings.clone_to_cstring(name, context.temp_allocator)
|
||||||
|
|
||||||
@@ -250,8 +252,12 @@ _lchown :: proc(name: string, uid, gid: int) -> Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_chtimes :: proc(name: string, atime, mtime: time.Time) -> Error {
|
_chtimes :: proc(name: string, atime, mtime: time.Time) -> Error {
|
||||||
//TODO
|
name_cstr := strings.clone_to_cstring(name, context.temp_allocator)
|
||||||
return nil
|
times := [2]Unix_File_Time {
|
||||||
|
{ atime._nsec, 0 },
|
||||||
|
{ mtime._nsec, 0 },
|
||||||
|
}
|
||||||
|
return _ok_or_error(unix.sys_utimensat(_AT_FDCWD, name_cstr, ×, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
_exists :: proc(name: string) -> bool {
|
_exists :: proc(name: string) -> bool {
|
||||||
|
|||||||
@@ -1779,6 +1779,12 @@ sys_fork :: proc() -> int {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE: Unsure about if this works directly on 32 bit archs. It may need 32 bit version of the time struct.
|
||||||
|
// As of Linux 5.1, there is a utimensat_time64 function. Maybe use this in the future?
|
||||||
|
sys_utimensat :: proc(dfd: int, path: cstring, times: rawptr, flags: int) -> int {
|
||||||
|
return int(intrinsics.syscall(SYS_utimensat, uintptr(dfd), uintptr(rawptr(path)), uintptr(times), uintptr(flags)))
|
||||||
|
}
|
||||||
|
|
||||||
get_errno :: proc(res: int) -> i32 {
|
get_errno :: proc(res: int) -> i32 {
|
||||||
if res < 0 && res > -4096 {
|
if res < 0 && res > -4096 {
|
||||||
return i32(-res)
|
return i32(-res)
|
||||||
|
|||||||
Reference in New Issue
Block a user