1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

os: add File.read_into_ptr (#11219)

This commit is contained in:
div72
2021-08-18 17:08:41 +03:00
committed by GitHub
parent b3c641f7d5
commit 2bf1015ae1

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() {