Skip to main content
Module

x/denops_std/function/mod.ts>readblob

📚 Standard module for denops.vim
Go to Latest
function readblob
import { readblob } from "https://deno.land/x/denops_std@v6.4.0/function/mod.ts";

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. This can be also used to read the data from a character device on Unix when {size} is explicitly set. Only if the device supports seeking {offset} can be used. Otherwise it should be zero. E.g. to read 10 bytes from a serial console:

readblob('/dev/ttyS0', 0, 10)

When the file can't be opened an error message is given and the result is an empty Blob. When the offset is beyond the end of the file the result is an empty blob. When trying to read more bytes than are available the result is truncated. Also see readfile() and writefile().

Parameters

denops: Denops
fname: unknown
optional
offset: unknown
optional
size: unknown

Returns

Promise<unknown>