(handle, cb)
| 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'); |
no test coverage detected