素材牛VIP会员
这个fs.read的API是不是错了?
 阿***逗  分类:Node.js  人气:679  回帖:2  发布于6年前 收藏

fs.read(fd, buffer, offset, length, position, callback)

Read data from the file specified by fd.

buffer is the buffer that the data will be written to.

offset is the offset in the buffer to start writing at.

为什么不是这样:

buffer is the buffer that the data will be read to.

offset is the offset in the buffer to start reading at.

 标签:node.js

讨论这个帖子(2)垃圾回帖将一律封号处理……

Lv1 新人
青***8 页面重构设计 6年前#1

(Nodejs) writes the data to buffer. The writing starts at offset.

Nodejs does read out the data from fd to buffer, but the reading starts at the offset that the operating system associated with fd.

If you read something, that thing is the source of some data, not data itself. Read a file, read an article, etc.

Lv1 新人
陈***1 学生 6年前#2

要把数据从文件里读出来写入buffer,offset也是buffer的偏移量

 文明上网,理性发言!   😉 阿里云幸运券,戳我领取