summaryrefslogtreecommitdiff
path: root/runtime/doc
diff options
context:
space:
mode:
authorK.Takata <kentkt@csc.jp>2022-10-19 14:02:40 +0100
committerBram Moolenaar <Bram@vim.org>2022-10-19 14:02:40 +0100
commit11df3aeee548b959ccd4b9a4d3c44651eab6b3ce (patch)
tree13cdeec4447038acdffe1084b3b5f91dabae038b /runtime/doc
parent9f62ea01a08e69f44050f59469a0e64beddefac0 (diff)
downloadvim-git-11df3aeee548b959ccd4b9a4d3c44651eab6b3ce.tar.gz
patch 9.0.0795: readblob() always reads the whole filev9.0.0795
Problem: readblob() always reads the whole file. Solution: Add arguments to read part of the file. (Ken Takata, closes #11402)
Diffstat (limited to 'runtime/doc')
-rw-r--r--runtime/doc/builtin.txt16
1 files changed, 14 insertions, 2 deletions
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index d1d18c5c7..9b46d2517 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -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()|.