| ... | @@ -85,13 +85,16 @@ pub const File = extern struct { | ... | @@ -85,13 +85,16 @@ pub const File = extern struct { |
| 85 | fn getEndPos(self: *const File) GetSeekPosError!u64 { | 85 | fn getEndPos(self: *const File) GetSeekPosError!u64 { |
| 86 | // preserve the old file position | 86 | // preserve the old file position |
| 87 | var pos: u64 = undefined; | 87 | var pos: u64 = undefined; |
| | 88 | var end_pos: u64 = undefined; |
| 88 | if (.Success != self.getPosition(&pos)) return GetSeekPosError.GetSeekPosError; | 89 | if (.Success != self.getPosition(&pos)) return GetSeekPosError.GetSeekPosError; |
| 89 | // seek to end of file to get position = file size | 90 | // seek to end of file to get position = file size |
| 90 | if (.Success != self.setPosition(efi_file_position_end_of_file)) return GetSeekPosError.GetSeekPosError; | 91 | if (.Success != self.setPosition(efi_file_position_end_of_file)) return GetSeekPosError.GetSeekPosError; |
| | 92 | // get the position |
| | 93 | if (.Success != self.getPosition(&end_pos)) return GetSeekPosError.GetSeekPosError; |
| 91 | // restore the old position | 94 | // restore the old position |
| 92 | if (.Success != self.setPosition(pos)) return GetSeekPosError.GetSeekPosError; | 95 | if (.Success != self.setPosition(pos)) return GetSeekPosError.GetSeekPosError; |
| 93 | // return the file size = position | 96 | // return the file size = position |
| 94 | return pos; | 97 | return end_pos; |
| 95 | } | 98 | } |
| 96 | | 99 | |
| 97 | pub fn setPosition(self: *const File, position: u64) Status { | 100 | pub fn setPosition(self: *const File, position: u64) Status { |