forked from aniani/vim
patch 9.0.0795: readblob() always reads the whole file
Problem: readblob() always reads the whole file.
Solution: Add arguments to read part of the file. (Ken Takata,
closes #11402)
This commit is contained in:
@@ -445,7 +445,8 @@ pyxeval({expr}) any evaluate |python_x| expression
|
||||
rand([{expr}]) Number get pseudo-random number
|
||||
range({expr} [, {max} [, {stride}]])
|
||||
List items from {expr} to {max}
|
||||
readblob({fname}) Blob read a |Blob| from {fname}
|
||||
readblob({fname} [, {offset} [, {size}]])
|
||||
Blob read a |Blob| from {fname}
|
||||
readdir({dir} [, {expr} [, {dict}]])
|
||||
List file names in {dir} selected by {expr}
|
||||
readdirex({dir} [, {expr} [, {dict}]])
|
||||
@@ -6847,10 +6848,21 @@ range({expr} [, {max} [, {stride}]]) *range()*
|
||||
GetExpr()->range()
|
||||
<
|
||||
|
||||
readblob({fname}) *readblob()*
|
||||
readblob({fname} [, {offset} [, {size}]]) *readblob()*
|
||||
Read file {fname} in binary mode and return a |Blob|.
|
||||
If {offset} is specified, read the file from the specified
|
||||
offset. If it is a negative value, it is used as an offset
|
||||
from the end of the file. E.g., to read the last 12 bytes: >
|
||||
readblob('file.bin', -12)
|
||||
< If {size} is specified, only the specified size will be read.
|
||||
E.g. to read the first 100 bytes of a file: >
|
||||
readblob('file.bin', 0, 100)
|
||||
< If {size} is -1 or omitted, the whole data starting from
|
||||
{offset} will be read.
|
||||
When the file can't be opened an error message is given and
|
||||
the result is an empty |Blob|.
|
||||
When trying to read bytes beyond the end of the file the
|
||||
result is an empty blob.
|
||||
Also see |readfile()| and |writefile()|.
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user