os: add File.read_into_ptr (#11219)
parent
b3c641f7d5
commit
2bf1015ae1
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue