mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-02 04:38:16 +00:00
os2: fixes after rebasing
This commit is contained in:
+17
-10
@@ -26,9 +26,9 @@ File_Impl :: struct {
|
|||||||
@(init)
|
@(init)
|
||||||
init_std_files :: proc() {
|
init_std_files :: proc() {
|
||||||
// NOTE: is this (paths) also the case on non darwin?
|
// NOTE: is this (paths) also the case on non darwin?
|
||||||
stdin = _new_file(posix.STDIN_FILENO, "/dev/stdin")
|
stdin = new_file(posix.STDIN_FILENO, "/dev/stdin")
|
||||||
stdout = _new_file(posix.STDOUT_FILENO, "/dev/stdout")
|
stdout = new_file(posix.STDOUT_FILENO, "/dev/stdout")
|
||||||
stderr = _new_file(posix.STDERR_FILENO, "/dev/stdout")
|
stderr = new_file(posix.STDERR_FILENO, "/dev/stdout")
|
||||||
}
|
}
|
||||||
|
|
||||||
_open :: proc(name: string, flags: File_Flags, perm: int) -> (f: ^File, err: Error) {
|
_open :: proc(name: string, flags: File_Flags, perm: int) -> (f: ^File, err: Error) {
|
||||||
@@ -63,27 +63,34 @@ _open :: proc(name: string, flags: File_Flags, perm: int) -> (f: ^File, err: Err
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
return _new_file(uintptr(fd), name), nil
|
return _new_file(uintptr(fd), name)
|
||||||
}
|
}
|
||||||
|
|
||||||
_new_file :: proc(handle: uintptr, name: string) -> ^File {
|
_new_file :: proc(handle: uintptr, name: string) -> (f: ^File, err: Error) {
|
||||||
if name == "" || handle == ~uintptr(0) {
|
if name == "" {
|
||||||
return nil
|
err = .Invalid_Path
|
||||||
|
return
|
||||||
|
} else if handle == ~uintptr(0) {
|
||||||
|
err = .Invalid_File
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
TEMP_ALLOCATOR_GUARD()
|
TEMP_ALLOCATOR_GUARD()
|
||||||
cname := temp_cstring(name)
|
cname := temp_cstring(name)
|
||||||
|
|
||||||
crname := posix.realpath(cname, nil)
|
crname := posix.realpath(cname, nil)
|
||||||
assert(crname != nil)
|
if crname == nil {
|
||||||
|
err = _get_platform_error()
|
||||||
|
return
|
||||||
|
}
|
||||||
rname := string(crname)
|
rname := string(crname)
|
||||||
|
|
||||||
f := __new_file(posix.FD(handle))
|
f = __new_file(posix.FD(handle))
|
||||||
impl := (^File_Impl)(f.impl)
|
impl := (^File_Impl)(f.impl)
|
||||||
impl.name = rname
|
impl.name = rname
|
||||||
impl.cname = crname
|
impl.cname = crname
|
||||||
|
|
||||||
return f
|
return f, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
__new_file :: proc(handle: posix.FD) -> ^File {
|
__new_file :: proc(handle: posix.FD) -> ^File {
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ internal_stat :: proc(stat: posix.stat_t, fullpath: string) -> (fi: File_Info) {
|
|||||||
fi.fullpath = fullpath
|
fi.fullpath = fullpath
|
||||||
fi.name = filepath.base(fi.fullpath)
|
fi.name = filepath.base(fi.fullpath)
|
||||||
|
|
||||||
fi.inode = u64(stat.st_ino)
|
fi.inode = u128(stat.st_ino)
|
||||||
fi.size = i64(stat.st_size)
|
fi.size = i64(stat.st_size)
|
||||||
|
|
||||||
fi.mode = int(transmute(posix._mode_t)(stat.st_mode - posix._S_IFMT))
|
fi.mode = int(transmute(posix._mode_t)(stat.st_mode - posix.S_IFMT))
|
||||||
|
|
||||||
fi.type = .Undetermined
|
fi.type = .Undetermined
|
||||||
switch {
|
switch {
|
||||||
|
|||||||
Reference in New Issue
Block a user