Skip to content

Commit

Permalink
Fixed windows getPos
Browse files Browse the repository at this point in the history
  • Loading branch information
Hejsil committed Jul 20, 2018
1 parent 0a880d5 commit 1f4c7d5
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions std/os/file.zig
Expand Up @@ -242,7 +242,7 @@ pub const File = struct {
},
Os.windows => {
var pos: windows.LARGE_INTEGER = undefined;
if (windows.SetFilePointerEx(self.handle, 0, *pos, windows.FILE_CURRENT) == 0) {
if (windows.SetFilePointerEx(self.handle, 0, &pos, windows.FILE_CURRENT) == 0) {
const err = windows.GetLastError();
return switch (err) {
windows.ERROR.INVALID_PARAMETER => error.BadFd,
Expand All @@ -251,13 +251,7 @@ pub const File = struct {
}

assert(pos >= 0);
if (@sizeOf(@typeOf(pos)) > @sizeOf(usize)) {
if (pos > @maxValue(usize)) {
return error.FilePosLargerThanPointerRange;
}
}

return usize(pos);
return math.cast(usize, pos) catch error.FilePosLargerThanPointerRange;
},
else => @compileError("unsupported OS"),
}
Expand Down

0 comments on commit 1f4c7d5

Please sign in to comment.