去掉getEndPos使用lseek,因为getEndPos需要用statx,这个在debian10没有……

This commit is contained in:
a92126 2024-11-20 18:01:25 +08:00
parent dbb4c28ffe
commit e17f8a4dd6

View File

@ -120,9 +120,14 @@ pub fn main() !void {
}
fn readAll(allocator: Allocator, file: File) ![]u8 {
const file_size: usize = @intCast(try file.getEndPos());
//const file_size: usize = @intCast(try file.getEndPos());
//const file_contents = try allocator.alloc(u8, file_size);
try file.seekFromEnd(0);
const file_size = try file.getPos();
const file_contents = try allocator.alloc(u8, file_size);
try file.seekTo(0);
const readed = try file.readAll(file_contents);
if (readed != file_size) {
return error.EndOfStream;