MCPcopy Index your code
hub / github.com/nodejs/node / FileHandleOperations

Function FileHandleOperations

lib/internal/fs/streams.js:87–116  ·  view source on GitHub ↗
(handle)

Source from the content-addressed store, hash-verified

85
86// This generates an fs operations structure for a FileHandle
87const FileHandleOperations = (handle) => {
88 return {
89 open: (path, flags, mode, cb) => {
90 throw new ERR_METHOD_NOT_IMPLEMENTED('open()');
91 },
92 close: (fd, cb) => {
93 handle[kUnref]();
94 PromisePrototypeThen(handle.close(),
95 () => cb(), cb);
96 },
97 fsync: (fd, cb) => {
98 PromisePrototypeThen(handle.sync(), () => cb(), cb);
99 },
100 read: (fd, buf, offset, length, pos, cb) => {
101 PromisePrototypeThen(handle.read(buf, offset, length, pos),
102 (r) => cb(null, r.bytesRead, r.buffer),
103 (err) => cb(err, 0, buf));
104 },
105 write: (fd, buf, offset, length, pos, cb) => {
106 PromisePrototypeThen(handle.write(buf, offset, length, pos),
107 (r) => cb(null, r.bytesWritten, r.buffer),
108 (err) => cb(err, 0, buf));
109 },
110 writev: (fd, buffers, pos, cb) => {
111 PromisePrototypeThen(handle.writev(buffers, pos),
112 (r) => cb(null, r.bytesWritten, r.buffers),
113 (err) => cb(err, 0, buffers));
114 },
115 };
116};
117
118function close(stream, err, cb) {
119 if (!stream.fd) {

Callers 1

importFdFunction · 0.85

Calls 6

closeMethod · 0.65
cbFunction · 0.50
syncMethod · 0.45
readMethod · 0.45
writeMethod · 0.45
writevMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…