mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 14:48:47 +00:00
fix os.read_dir closing the given file descriptor
This commit is contained in:
@@ -389,6 +389,7 @@ foreign libc {
|
||||
@(link_name="rmdir") _unix_rmdir :: proc(path: cstring) -> c.int ---
|
||||
@(link_name="mkdir") _unix_mkdir :: proc(path: cstring, mode: mode_t) -> c.int ---
|
||||
@(link_name="fcntl") _unix_fcntl :: proc(fd: Handle, cmd: c.int, arg: uintptr) -> c.int ---
|
||||
@(link_name="dup") _unix_dup :: proc(fd: Handle) -> Handle ---
|
||||
|
||||
@(link_name="fdopendir") _unix_fdopendir :: proc(fd: Handle) -> Dir ---
|
||||
@(link_name="closedir") _unix_closedir :: proc(dirp: Dir) -> c.int ---
|
||||
@@ -739,6 +740,15 @@ _readlink :: proc(path: string) -> (string, Error) {
|
||||
return "", Error{}
|
||||
}
|
||||
|
||||
@(private, require_results)
|
||||
_dup :: proc(fd: Handle) -> (Handle, Error) {
|
||||
dup := _unix_dup(fd)
|
||||
if dup == -1 {
|
||||
return INVALID_HANDLE, get_last_error()
|
||||
}
|
||||
return dup, nil
|
||||
}
|
||||
|
||||
@(require_results)
|
||||
absolute_path_from_handle :: proc(fd: Handle) -> (string, Error) {
|
||||
// NOTE(Feoramund): The situation isn't ideal, but this was the best way I
|
||||
|
||||
Reference in New Issue
Block a user