Skip to content

Commit 1f4c7d5

Browse files
committedJul 20, 2018
Fixed windows getPos
1 parent 0a880d5 commit 1f4c7d5

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed
 

‎std/os/file.zig

+2-8
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ pub const File = struct {
242242
},
243243
Os.windows => {
244244
var pos: windows.LARGE_INTEGER = undefined;
245-
if (windows.SetFilePointerEx(self.handle, 0, *pos, windows.FILE_CURRENT) == 0) {
245+
if (windows.SetFilePointerEx(self.handle, 0, &pos, windows.FILE_CURRENT) == 0) {
246246
const err = windows.GetLastError();
247247
return switch (err) {
248248
windows.ERROR.INVALID_PARAMETER => error.BadFd,
@@ -251,13 +251,7 @@ pub const File = struct {
251251
}
252252

253253
assert(pos >= 0);
254-
if (@sizeOf(@typeOf(pos)) > @sizeOf(usize)) {
255-
if (pos > @maxValue(usize)) {
256-
return error.FilePosLargerThanPointerRange;
257-
}
258-
}
259-
260-
return usize(pos);
254+
return math.cast(usize, pos) catch error.FilePosLargerThanPointerRange;
261255
},
262256
else => @compileError("unsupported OS"),
263257
}

0 commit comments

Comments
 (0)
Please sign in to comment.