libuv 笔记

参数

uv_fs_cb

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

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 <sys/uio.h> as:

Synopsis

#include <sys/uio.h>

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 <sys/uio.h> 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中表示打开的文件描述符.

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • https://nodejs.org/api/documentation.html 工具模块 Assert 测试 ...
    KeKeMars阅读 6,420评论 0 6
  • mean to add the formatted="false" attribute?.[ 46% 47325/...
    ProZoom阅读 2,729评论 0 3
  • Lua 5.1 参考手册 by Roberto Ierusalimschy, Luiz Henrique de F...
    苏黎九歌阅读 13,932评论 0 38
  • 坚持一件事情,总是感觉很难。 把它变成不需要坚持而坚持的事情,你就成功了一半,这就是对自己要说的话。 从7月份开始...
    李明涛阅读 255评论 0 0
  • 沪上秋风起,着身已微凉。 上午小熊那里传来捷报:跟楚楚街和豆果美食的合作谈下来了!事实证明,对我们产品感兴趣的用户...
    任宁阅读 382评论 0 2