| author | |
| committer | |
| log | 90714a38311ec79500c0257670985bfe5d6c9a1b |
| tree | 2c7c7338b1392a4cd8063805f97092733340fc9e |
| parent | 0aae96b5f0a592ee3e2ff3607121740042878634 |
2 files changed, 38 insertions(+), 0 deletions(-)
std/io.zig+30| ... | ... | @@ -204,6 +204,15 @@ pub const File = struct { |
| 204 | 204 | }; |
| 205 | 205 | } |
| 206 | 206 | }, |
| 207 | Os.windows => { | |
| 208 | if (system.SetFilePointerEx(self.handle, amount, null, system.FILE_CURRENT) == 0) { | |
| 209 | const err = system.GetLastError(); | |
| 210 | return switch (err) { | |
| 211 | system.ERROR.INVALID_PARAMETER => error.BadFd, | |
| 212 | else => os.unexpectedErrorPosix(err), | |
| 213 | }; | |
| 214 | } | |
| 215 | }, | |
| 207 | 216 | else => @compileError("unsupported OS"), |
| 208 | 217 | } |
| 209 | 218 | } |
| ... | ... | @@ -224,6 +233,15 @@ pub const File = struct { |
| 224 | 233 | }; |
| 225 | 234 | } |
| 226 | 235 | }, |
| 236 | Os.windows => { | |
| 237 | if (system.SetFilePointerEx(self.handle, @bitCast(isize, pos), null, system.FILE_BEGIN) == 0) { | |
| 238 | const err = system.GetLastError(); | |
| 239 | return switch (err) { | |
| 240 | system.ERROR.INVALID_PARAMETER => error.BadFd, | |
| 241 | else => os.unexpectedErrorWindows(err), | |
| 242 | }; | |
| 243 | } | |
| 244 | }, | |
| 227 | 245 | else => @compileError("unsupported OS: " ++ @tagName(builtin.os)), |
| 228 | 246 | } |
| 229 | 247 | } |
| ... | ... | @@ -245,6 +263,18 @@ pub const File = struct { |
| 245 | 263 | } |
| 246 | 264 | return result; |
| 247 | 265 | }, |
| 266 | Os.windows => { | |
| 267 | var pos : usize = undefined; | |
| 268 | if (system.SetFilePointerEx(self.handle, 0, @ptrCast(system.PLARGE_INTEGER, &pos), system.FILE_CURRENT) == 0) { | |
| 269 | const err = system.GetLastError(); | |
| 270 | return switch (err) { | |
| 271 | system.ERROR.INVALID_PARAMETER => error.BadFd, | |
| 272 | else => os.unexpectedErrorWindows(err), | |
| 273 | }; | |
| 274 | } | |
| 275 | ||
| 276 | return pos; | |
| 277 | }, | |
| 248 | 278 | else => @compileError("unsupported OS"), |
| 249 | 279 | } |
| 250 | 280 | } |
std/os/windows/index.zig+8| ... | ... | @@ -74,6 +74,9 @@ pub extern "kernel32" stdcallcc fn ReadFile(in_hFile: HANDLE, out_lpBuffer: LPVO |
| 74 | 74 | in_nNumberOfBytesToRead: DWORD, out_lpNumberOfBytesRead: &DWORD, |
| 75 | 75 | in_out_lpOverlapped: ?&OVERLAPPED) -> BOOL; |
| 76 | 76 | |
| 77 | pub extern "kernel32" stdcallcc fn SetFilePointerEx(in_fFile: HANDLE, in_liDistanceToMove: LARGE_INTEGER, | |
| 78 | out_opt_ldNewFilePointer: ?PLARGE_INTEGER, in_dwMoveMethod: DWORD) -> BOOL; | |
| 79 | ||
| 77 | 80 | pub extern "kernel32" stdcallcc fn SetHandleInformation(hObject: HANDLE, dwMask: DWORD, dwFlags: DWORD) -> BOOL; |
| 78 | 81 | |
| 79 | 82 | pub extern "kernel32" stdcallcc fn Sleep(dwMilliseconds: DWORD); |
| ... | ... | @@ -126,6 +129,7 @@ pub const UNICODE = false; |
| 126 | 129 | pub const WCHAR = u16; |
| 127 | 130 | pub const WORD = u16; |
| 128 | 131 | pub const LARGE_INTEGER = i64; |
| 132 | pub const PLARGE_INTEGER = &LARGE_INTEGER; | |
| 129 | 133 | |
| 130 | 134 | pub const TRUE = 1; |
| 131 | 135 | pub const FALSE = 0; |
| ... | ... | @@ -289,3 +293,7 @@ pub const MOVEFILE_DELAY_UNTIL_REBOOT = 4; |
| 289 | 293 | pub const MOVEFILE_FAIL_IF_NOT_TRACKABLE = 32; |
| 290 | 294 | pub const MOVEFILE_REPLACE_EXISTING = 1; |
| 291 | 295 | pub const MOVEFILE_WRITE_THROUGH = 8; |
| 296 | ||
| 297 | pub const FILE_BEGIN = 0; | |
| 298 | pub const FILE_CURRENT = 1; | |
| 299 | pub const FILE_END = 2; | |
| \ No newline at end of file |