libuv 笔记

参数

uv_fs_cb

文件系统的回调函数
文件系统的回调函数有如下的形式:
void callback(uv_fs_t* req);

libuv 笔记_第1张图片
image


uv_fs_read

原型 int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, uv_file file, const uv_buf_t bufs[], unsigned int nbufs, int64_t offset, uv_fs_cb cb)
他的作用等价于preadv(2)

iov

The pointer iov points to an array of iovec structures, defined in as:

Synopsis

#include 

ssize_t readv(int fd, const struct iovec *iov, int iovcnt);

ssize_t writev(int fd, const struct iovec *iov, int iovcnt);

ssize_t preadv(int fd, const struct iovec *iov, int iovcnt,
               off_t offset);

ssize_t pwritev(int fd, const struct iovec *iov, int iovcnt,
                off_t offset);
The pointer iov points to an array of iovec structures, defined in  as:

struct iovec {
    void  *iov_base;    /* Starting address */
    size_t iov_len;     /* Number of bytes to transfer */
};

The preadv() system call combines the functionality of readv() and pread(2). It performs the same task as readv(), but adds a fourth argument, offset, which specifies the file offset at which the input operation is to be performed.


uv_fs_t.result

保存返回值,返回的result值,0表示出错,其他值表示成功。但>=0的值在不同的函数中表示的意义不一样,比如在uv_fs_read或者uv_fs_write中,它代表读取或写入的数据总量,但在uv_fs_open中表示打开的文件描述符.

你可能感兴趣的:(libuv 笔记)