Fixed windows getPos

master
Jimmi HC 2018-07-20 23:05:53 +02:00
parent 0a880d5e60
commit 1f4c7d5ebf
1 changed files with 2 additions and 8 deletions

View File

@ -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,
@ -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"),
}