os: deprecate read_at and add read_from to implement RandomReader (#9371)

pull/9375/head
zakuro 2021-03-19 19:35:08 +09:00 committed by GitHub
parent f8fcf3ff66
commit 29884fa2a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -287,7 +287,13 @@ pub fn (f &File) read(mut buf []byte) ?int {
}
// read_at reads `buf.len` bytes starting at file byte offset `pos`, in `buf`.
[deprecated: 'use File.read_from() instead']
pub fn (f &File) read_at(pos int, mut buf []byte) ?int {
return f.read_from(pos, mut buf)
}
// read_from implements the RandomReader interface.
pub fn (f &File) read_from(pos int, mut buf []byte) ?int {
if buf.len == 0 {
return 0
}