javascript / node.js中的seek()等价物? [英] seek() equivalent in javascript/node.js?
问题描述
我目前正在尝试使用fs模块为node.js读取一些文件。
因为它缺少我曾经使用过的函数(fseek(),getline()...),所以我创建了另一个模块来取回它们。 (C stdio.h的node.js副本)。
I m currently trying to read some files with fs module for node.js. Since it lack a tot of the function I m used to (fseek(), getline()...), I m creating another module to get them back. (a node.js copy of C stdio.h).
我的简单问题是:
seek()是否存在于其他名称中,或者我是否需要重新填充几乎每个函数才能拥有它?
推荐答案
在node.js中, seek
功能包含在 read
函数中。当您使用 fs.read
函数时,有一个名为 position
的参数,作为搜索位置。
In node.js the seek
functionality is included in the read
function. When you use the fs.read
function, there is a parameter called position
, that works as the seek position.
如果你想要的是写入文件,函数 fs.write
也有 position
参数。
If what you want is to write to the file, the function fs.write
also has the position
parameter.
检查这里的文档:
https://nodejs.org/api/fs.html#fs_fs_read_fd_buffer_offset_length_position_callback
这篇关于javascript / node.js中的seek()等价物?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!