(path, attrs, cb)
| 1061 | ); |
| 1062 | } |
| 1063 | setstat(path, attrs, cb) { |
| 1064 | if (this.server) |
| 1065 | throw new Error('Client-only method called in server mode'); |
| 1066 | |
| 1067 | let flags = 0; |
| 1068 | let attrsLen = 0; |
| 1069 | |
| 1070 | if (typeof attrs === 'object' && attrs !== null) { |
| 1071 | attrs = attrsToBytes(attrs); |
| 1072 | flags = attrs.flags; |
| 1073 | attrsLen = attrs.nb; |
| 1074 | } else if (typeof attrs === 'function') { |
| 1075 | cb = attrs; |
| 1076 | } |
| 1077 | |
| 1078 | /* |
| 1079 | uint32 id |
| 1080 | string path |
| 1081 | ATTRS attrs |
| 1082 | */ |
| 1083 | const pathLen = Buffer.byteLength(path); |
| 1084 | let p = 9; |
| 1085 | const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen + 4 + attrsLen); |
| 1086 | |
| 1087 | writeUInt32BE(buf, buf.length - 4, 0); |
| 1088 | buf[4] = REQUEST.SETSTAT; |
| 1089 | const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID; |
| 1090 | writeUInt32BE(buf, reqid, 5); |
| 1091 | |
| 1092 | writeUInt32BE(buf, pathLen, p); |
| 1093 | buf.utf8Write(path, p += 4, pathLen); |
| 1094 | writeUInt32BE(buf, flags, p += pathLen); |
| 1095 | if (attrsLen) { |
| 1096 | p += 4; |
| 1097 | |
| 1098 | if (attrsLen === ATTRS_BUF.length) |
| 1099 | buf.set(ATTRS_BUF, p); |
| 1100 | else |
| 1101 | bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p); |
| 1102 | |
| 1103 | p += attrsLen; |
| 1104 | } |
| 1105 | |
| 1106 | this._requests[reqid] = { cb }; |
| 1107 | |
| 1108 | const isBuffered = sendOrBuffer(this, buf); |
| 1109 | this._debug && this._debug( |
| 1110 | `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} SETSTAT` |
| 1111 | ); |
| 1112 | } |
| 1113 | fsetstat(handle, attrs, cb) { |
| 1114 | if (this.server) |
| 1115 | throw new Error('Client-only method called in server mode'); |
no test coverage detected