os: add File.read_into_ptr (#11219)

pull/11234/head
div72 2021-08-18 17:08:41 +03:00 committed by GitHub
parent b3c641f7d5
commit 2bf1015ae1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -463,6 +463,12 @@ pub fn (f &File) read_from(pos u64, mut buf []byte) ?int {
return error('Could not read file')
}
// read_into_ptr reads at most max_size bytes from the file and writes it into ptr.
// Returns the amount of bytes read or an error.
pub fn (f &File) read_into_ptr(ptr &byte, max_size int) ?int {
return fread(ptr, 1, max_size, f.cfile)
}
// **************************** Utility ops ***********************
// flush writes any buffered unwritten data left in the file stream.
pub fn (mut f File) flush() {