(reqid, attrs)
| 2055 | ); |
| 2056 | } |
| 2057 | attrs(reqid, attrs) { |
| 2058 | if (!this.server) |
| 2059 | throw new Error('Server-only method called in client mode'); |
| 2060 | |
| 2061 | if (typeof attrs !== 'object' || attrs === null) |
| 2062 | throw new Error('attrs is not an object'); |
| 2063 | |
| 2064 | attrs = attrsToBytes(attrs); |
| 2065 | const flags = attrs.flags; |
| 2066 | const attrsLen = attrs.nb; |
| 2067 | let p = 9; |
| 2068 | const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + attrsLen); |
| 2069 | |
| 2070 | writeUInt32BE(buf, buf.length - 4, 0); |
| 2071 | buf[4] = RESPONSE.ATTRS; |
| 2072 | writeUInt32BE(buf, reqid, 5); |
| 2073 | |
| 2074 | writeUInt32BE(buf, flags, p); |
| 2075 | if (attrsLen) { |
| 2076 | p += 4; |
| 2077 | |
| 2078 | if (attrsLen === ATTRS_BUF.length) |
| 2079 | buf.set(ATTRS_BUF, p); |
| 2080 | else |
| 2081 | bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p); |
| 2082 | |
| 2083 | p += attrsLen; |
| 2084 | } |
| 2085 | |
| 2086 | const isBuffered = sendOrBuffer(this, buf); |
| 2087 | this._debug && this._debug( |
| 2088 | `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} ATTRS` |
| 2089 | ); |
| 2090 | } |
| 2091 | } |
| 2092 | |
| 2093 | function tryCreateBuffer(size) { |
no test coverage detected