Random access in node.js

感情迁移 提交于 2021-02-11 05:08:28

问题


Does node.js support writing random access?

I see this package, but it doesn't work (if I write two or more parts, the file is corrupt)


回答1:


fs core library should suffice for that. Here is the list of functions to use:

  1. fs.open(path, flags, [mode], callback)
  2. fs.write(fd, buffer, offset, length, position, callback)
  3. fs.writeSync(fd, buffer, offset, length, position)
  4. fs.read(fd, buffer, offset, length, position, callback)
  5. fs.readSync(fd, buffer, offset, length, position)

They are analogous to how you would do it in C.



来源:https://stackoverflow.com/questions/24230135/random-access-in-node-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!