MCPcopy Create free account
hub / github.com/mscdex/ssh2 / close

Method close

lib/protocol/SFTP.js:372–401  ·  view source on GitHub ↗
(handle, cb)

Source from the content-addressed store, hash-verified

370 );
371 }
372 close(handle, cb) {
373 if (this.server)
374 throw new Error('Client-only method called in server mode');
375
376 if (!Buffer.isBuffer(handle))
377 throw new Error('handle is not a Buffer');
378
379 /*
380 uint32 id
381 string handle
382 */
383 const handleLen = handle.length;
384 let p = 9;
385 const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen);
386
387 writeUInt32BE(buf, buf.length - 4, 0);
388 buf[4] = REQUEST.CLOSE;
389 const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;
390 writeUInt32BE(buf, reqid, 5);
391
392 writeUInt32BE(buf, handleLen, p);
393 buf.set(handle, p += 4);
394
395 this._requests[reqid] = { cb };
396
397 const isBuffered = sendOrBuffer(this, buf);
398 this._debug && this._debug(
399 `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} CLOSE`
400 );
401 }
402 read(handle, buf, off, len, position, cb) {
403 if (this.server)
404 throw new Error('Client-only method called in server mode');

Callers 8

afterReadMethod · 0.95
tryStatMethod · 0.95
rereadMethod · 0.95
_closeFunction · 0.45
onerrorFunction · 0.45
writeCbFunction · 0.45
writeAllFunction · 0.45
closeStreamFunction · 0.45

Calls 4

writeUInt32BEFunction · 0.85
sendOrBufferFunction · 0.85
bufferSliceFunction · 0.85
callbackFunction · 0.85

Tested by

no test coverage detected