| author | |
| committer | |
| log | 20c2dbdbd3847cfaa580878fca2566347a2f4733 |
| tree | ade52bac91ed59d135e700fec593b74bf4623f2b |
| parent | 1ac46fac15953820948b77b94083828f84673641 |
2 files changed, 25 insertions(+), 9 deletions(-)
std/io.zig+22-9| ... | @@ -253,17 +253,30 @@ pub const File = struct { | ... | @@ -253,17 +253,30 @@ pub const File = struct { |
| 253 | } | 253 | } |
| 254 | 254 | ||
| 255 | pub fn getEndPos(self: &File) -> %usize { | 255 | pub fn getEndPos(self: &File) -> %usize { |
| 256 | var stat: system.Stat = undefined; | 256 | if (is_posix) { |
| 257 | const err = system.getErrno(system.fstat(self.handle, &stat)); | 257 | var stat: system.Stat = undefined; |
| 258 | if (err > 0) { | 258 | const err = system.getErrno(system.fstat(self.handle, &stat)); |
| 259 | return switch (err) { | 259 | if (err > 0) { |
| 260 | system.EBADF => error.BadFd, | 260 | return switch (err) { |
| 261 | system.ENOMEM => error.OutOfMemory, | 261 | system.EBADF => error.BadFd, |
| 262 | else => os.unexpectedErrorPosix(err), | 262 | system.ENOMEM => error.OutOfMemory, |
| 263 | else => os.unexpectedErrorPosix(err), | ||
| 264 | } | ||
| 263 | } | 265 | } |
| 264 | } | ||
| 265 | 266 | ||
| 266 | return usize(stat.size); | 267 | return usize(stat.size); |
| 268 | } else if (is_windows) { | ||
| 269 | var file_size: system.LARGE_INTEGER = undefined; | ||
| 270 | if (system.GetFileSizeEx(self.handle, &file_size) == 0) { | ||
| 271 | const err = system.GetLastError(); | ||
| 272 | return switch (err) { | ||
| 273 | else => os.unexpectedErrorWindows(err), | ||
| 274 | }; | ||
| 275 | } | ||
| 276 | return @bitCast(usize, file_size); | ||
| 277 | } else { | ||
| 278 | unreachable; | ||
| 279 | } | ||
| 267 | } | 280 | } |
| 268 | 281 | ||
| 269 | pub fn read(self: &File, buffer: []u8) -> %usize { | 282 | pub fn read(self: &File, buffer: []u8) -> %usize { |
std/os/windows/index.zig+3| ... | @@ -46,6 +46,8 @@ pub extern "kernel32" stdcallcc fn GetEnvironmentVariableA(lpName: LPCSTR, lpBuf | ... | @@ -46,6 +46,8 @@ pub extern "kernel32" stdcallcc fn GetEnvironmentVariableA(lpName: LPCSTR, lpBuf |
| 46 | 46 | ||
| 47 | pub extern "kernel32" stdcallcc fn GetExitCodeProcess(hProcess: HANDLE, lpExitCode: &DWORD) -> BOOL; | 47 | pub extern "kernel32" stdcallcc fn GetExitCodeProcess(hProcess: HANDLE, lpExitCode: &DWORD) -> BOOL; |
| 48 | 48 | ||
| 49 | pub extern "kernel32" stdcallcc fn GetFileSizeEx(hFile: HANDLE, lpFileSize: &LARGE_INTEGER) -> BOOL; | ||
| 50 | |||
| 49 | pub extern "kernel32" stdcallcc fn GetLastError() -> DWORD; | 51 | pub extern "kernel32" stdcallcc fn GetLastError() -> DWORD; |
| 50 | 52 | ||
| 51 | pub extern "kernel32" stdcallcc fn GetFileInformationByHandleEx(in_hFile: HANDLE, | 53 | pub extern "kernel32" stdcallcc fn GetFileInformationByHandleEx(in_hFile: HANDLE, |
| ... | @@ -115,6 +117,7 @@ pub const ULONG_PTR = usize; | ... | @@ -115,6 +117,7 @@ pub const ULONG_PTR = usize; |
| 115 | pub const UNICODE = false; | 117 | pub const UNICODE = false; |
| 116 | pub const WCHAR = u16; | 118 | pub const WCHAR = u16; |
| 117 | pub const WORD = u16; | 119 | pub const WORD = u16; |
| 120 | pub const LARGE_INTEGER = i64; | ||
| 118 | 121 | ||
| 119 | pub const TRUE = 1; | 122 | pub const TRUE = 1; |
| 120 | pub const FALSE = 0; | 123 | pub const FALSE = 0; |