Browse Source

Merge pull request #5079 from herohiralal/master

Pipe size on windows.
Jeroen van Rijn 4 months ago
parent
commit
7d4c3d23e6
1 changed files with 7 additions and 2 deletions
  1. 7 2
      core/os/os2/file_windows.odin

+ 7 - 2
core/os/os2/file_windows.odin

@@ -506,10 +506,15 @@ _write_at :: proc(f: ^File_Impl, p: []byte, offset: i64) -> (n: i64, err: Error)
 
 _file_size :: proc(f: ^File_Impl) -> (n: i64, err: Error) {
 	length: win32.LARGE_INTEGER
+	handle := _handle(&f.file)
 	if f.kind == .Pipe {
-		return 0, .No_Size
+		bytesAvail: u32
+		if win32.PeekNamedPipe(handle, nil, 0, nil, &bytesAvail, nil) {
+			return i64(bytesAvail), nil
+		} else {
+			return 0, .No_Size
+		}
 	}
-	handle := _handle(&f.file)
 	if !win32.GetFileSizeEx(handle, &length) {
 		err = _get_platform_error()
 	}