mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-03 22:28:46 +00:00
fix os.read_dir closing the given file descriptor
This commit is contained in:
+11
-1
@@ -598,7 +598,8 @@ foreign libc {
|
||||
@(link_name="fstat64") _unix_fstat :: proc(fd: Handle, stat: ^OS_Stat) -> c.int ---
|
||||
@(link_name="readlink") _unix_readlink :: proc(path: cstring, buf: ^byte, bufsiz: c.size_t) -> c.ssize_t ---
|
||||
@(link_name="access") _unix_access :: proc(path: cstring, mask: c.int) -> c.int ---
|
||||
@(link_name="fsync") _unix_fsync :: proc(handle: Handle) -> c.int ---
|
||||
@(link_name="fsync") _unix_fsync :: proc(handle: Handle) -> c.int ---
|
||||
@(link_name="dup") _unix_dup :: proc(handle: Handle) -> Handle ---
|
||||
|
||||
@(link_name="fdopendir$INODE64") _unix_fdopendir_amd64 :: proc(fd: Handle) -> Dir ---
|
||||
@(link_name="readdir_r$INODE64") _unix_readdir_r_amd64 :: proc(dirp: Dir, entry: ^Dirent, result: ^^Dirent) -> c.int ---
|
||||
@@ -1009,6 +1010,15 @@ _readlink :: proc(path: string) -> (string, 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) -> (path: string, err: Error) {
|
||||
buf: [DARWIN_MAXPATHLEN]byte
|
||||
|
||||
Reference in New Issue
Block a user