Browse Source

make sure an eof is also returned from the file streams on non-windows

Laytan Laats 1 year ago
parent
commit
7eabeda870
1 changed files with 8 additions and 0 deletions
  1. 8 0
      core/os/stream.odin

+ 8 - 0
core/os/stream.odin

@@ -54,6 +54,7 @@ _file_stream_proc :: proc(stream_data: rawptr, mode: io.Stream_Mode, p: []byte,
 			return io.query_utility({.Close, .Flush, .Read, .Read_At, .Write, .Write_At, .Seek, .Size, .Query})
 			return io.query_utility({.Close, .Flush, .Read, .Read_At, .Write, .Write_At, .Seek, .Size, .Query})
 		}
 		}
 	}
 	}
+
 	if err == nil && os_err != 0 {
 	if err == nil && os_err != 0 {
 		when ODIN_OS == .Windows {
 		when ODIN_OS == .Windows {
 			if os_err == ERROR_HANDLE_EOF {
 			if os_err == ERROR_HANDLE_EOF {
@@ -62,5 +63,12 @@ _file_stream_proc :: proc(stream_data: rawptr, mode: io.Stream_Mode, p: []byte,
 		}
 		}
 		err = .Unknown
 		err = .Unknown
 	}
 	}
+
+	when ODIN_OS != .Windows {
+		if err == nil && os_err == 0 && n == 0 {
+			err = .EOF
+		}
+	}
+
 	return
 	return
 }
 }