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

Method handle

lib/protocol/SFTP.js:1837–1864  ·  view source on GitHub ↗
(reqid, handle)

Source from the content-addressed store, hash-verified

1835 // Server-specific ===========================================================
1836 // ===========================================================================
1837 handle(reqid, handle) {
1838 if (!this.server)
1839 throw new Error('Server-only method called in client mode');
1840
1841 if (!Buffer.isBuffer(handle))
1842 throw new Error('handle is not a Buffer');
1843
1844 const handleLen = handle.length;
1845
1846 if (handleLen > 256)
1847 throw new Error('handle too large (> 256 bytes)');
1848
1849 let p = 9;
1850 const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen);
1851
1852 writeUInt32BE(buf, buf.length - 4, 0);
1853 buf[4] = RESPONSE.HANDLE;
1854 writeUInt32BE(buf, reqid, 5);
1855
1856 writeUInt32BE(buf, handleLen, p);
1857 if (handleLen)
1858 buf.set(handle, p += 4);
1859
1860 const isBuffered = sendOrBuffer(this, buf);
1861 this._debug && this._debug(
1862 `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} HANDLE`
1863 );
1864 }
1865 status(reqid, code, message) {
1866 if (!this.server)
1867 throw new Error('Server-only method called in client mode');

Callers 2

test-sftp.jsFile · 0.80

Calls 2

writeUInt32BEFunction · 0.85
sendOrBufferFunction · 0.85

Tested by

no test coverage detected