(handle, attrs, cb)
| 1111 | ); |
| 1112 | } |
| 1113 | fsetstat(handle, attrs, cb) { |
| 1114 | if (this.server) |
| 1115 | throw new Error('Client-only method called in server mode'); |
| 1116 | |
| 1117 | if (!Buffer.isBuffer(handle)) |
| 1118 | throw new Error('handle is not a Buffer'); |
| 1119 | |
| 1120 | let flags = 0; |
| 1121 | let attrsLen = 0; |
| 1122 | |
| 1123 | if (typeof attrs === 'object' && attrs !== null) { |
| 1124 | attrs = attrsToBytes(attrs); |
| 1125 | flags = attrs.flags; |
| 1126 | attrsLen = attrs.nb; |
| 1127 | } else if (typeof attrs === 'function') { |
| 1128 | cb = attrs; |
| 1129 | } |
| 1130 | |
| 1131 | /* |
| 1132 | uint32 id |
| 1133 | string handle |
| 1134 | ATTRS attrs |
| 1135 | */ |
| 1136 | const handleLen = handle.length; |
| 1137 | let p = 9; |
| 1138 | const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + handleLen + 4 + attrsLen); |
| 1139 | |
| 1140 | writeUInt32BE(buf, buf.length - 4, 0); |
| 1141 | buf[4] = REQUEST.FSETSTAT; |
| 1142 | const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID; |
| 1143 | writeUInt32BE(buf, reqid, 5); |
| 1144 | |
| 1145 | writeUInt32BE(buf, handleLen, p); |
| 1146 | buf.set(handle, p += 4); |
| 1147 | writeUInt32BE(buf, flags, p += handleLen); |
| 1148 | if (attrsLen) { |
| 1149 | p += 4; |
| 1150 | |
| 1151 | if (attrsLen === ATTRS_BUF.length) |
| 1152 | buf.set(ATTRS_BUF, p); |
| 1153 | else |
| 1154 | bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p); |
| 1155 | |
| 1156 | p += attrsLen; |
| 1157 | } |
| 1158 | |
| 1159 | this._requests[reqid] = { cb }; |
| 1160 | |
| 1161 | const isBuffered = sendOrBuffer(this, buf); |
| 1162 | this._debug && this._debug( |
| 1163 | `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} FSETSTAT` |
| 1164 | ); |
| 1165 | } |
| 1166 | futimes(handle, atime, mtime, cb) { |
| 1167 | return this.fsetstat(handle, { |
| 1168 | atime: toUnixTimestamp(atime), |
no test coverage detected