Hi,

Bram Moolenaar schrieb am 19.10.2022 um 15:03:
[...]
>   
> ! 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()|.

I think the second to last sentence needs a clarification. What happens if
reading starts inside the file, but the number of bytes to read would result
in reading beyond the end of file? For example, in the given example

  readblob('file.bin', 0, 100)

what would the result be if the file is only 80 bytes large? An empty blob
or a blob with 80 bytes? A constructed, but similar example

  readblob('file.bin', -10, 
function_that_might_return_a_number_larger_than_10())

Does the resulting blob contain 10 bytes if the function returns a number larger
than 10 or is the blob empty in this case?

(I would prefer readblob() to return as many bytes as possible and only to 
return
an empty blob if the reading *starts* beyond the end of the file. Currently I am
at a computer where I cannot update to the newest version, so I could not test
the actual behavior.)

Regards,
Jürgen

-- 
~
~
~
:wq

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/81c6dfc4-6f9e-7518-3553-92e607aced56%40googlemail.com.

Raspunde prin e-mail lui