Welcome to little lamb

Code » limb » release » tree

[release] / src / doc / allreadwrite.h / allread.3.md

% limb manual
% allread(3)
% limb 0.1.0
% 2023-07-24

# NAME

allread, allreadv - read requested amount of data from a file

# SYNOPSIS

    #include <limb/allreadwrite.h>

```pre hl
size_t allread(int <em>fd</em>, char *<em>dst</em>, size_t <em>dlen</em>)
size_t allreadv(int <em>fd</em>, const struct iovec *<em>v</em>, unsigned <em>n</em>)
```

# DESCRIPTION

The `allread`() function will attempt to read `dlen` bytes from the file
associated with file descriptor `fd` and copy them into the memory pointed by
`dst`.

The `allreadv`() function is similar only placing the data into the memory
described by the array `v` of `n` vectors.

# RETURN VALUE

These functions return the number of bytes read, which may be less than `dlen`
(even 0) in case of error, or if end-of-file was reached prior.

! HINT:
! To know whether an error occurred or not, you might want to set `errno` to 0
! prior to the call, and check it afterwards.