(path, attrs, cb)
| 785 | ); |
| 786 | } |
| 787 | mkdir(path, attrs, cb) { |
| 788 | if (this.server) |
| 789 | throw new Error('Client-only method called in server mode'); |
| 790 | |
| 791 | let flags = 0; |
| 792 | let attrsLen = 0; |
| 793 | |
| 794 | if (typeof attrs === 'function') { |
| 795 | cb = attrs; |
| 796 | attrs = undefined; |
| 797 | } |
| 798 | if (typeof attrs === 'object' && attrs !== null) { |
| 799 | attrs = attrsToBytes(attrs); |
| 800 | flags = attrs.flags; |
| 801 | attrsLen = attrs.nb; |
| 802 | } |
| 803 | |
| 804 | /* |
| 805 | uint32 id |
| 806 | string path |
| 807 | ATTRS attrs |
| 808 | */ |
| 809 | const pathLen = Buffer.byteLength(path); |
| 810 | let p = 9; |
| 811 | const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen + 4 + attrsLen); |
| 812 | |
| 813 | writeUInt32BE(buf, buf.length - 4, 0); |
| 814 | buf[4] = REQUEST.MKDIR; |
| 815 | const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID; |
| 816 | writeUInt32BE(buf, reqid, 5); |
| 817 | |
| 818 | writeUInt32BE(buf, pathLen, p); |
| 819 | buf.utf8Write(path, p += 4, pathLen); |
| 820 | writeUInt32BE(buf, flags, p += pathLen); |
| 821 | if (attrsLen) { |
| 822 | p += 4; |
| 823 | |
| 824 | if (attrsLen === ATTRS_BUF.length) |
| 825 | buf.set(ATTRS_BUF, p); |
| 826 | else |
| 827 | bufferCopy(ATTRS_BUF, buf, 0, attrsLen, p); |
| 828 | |
| 829 | p += attrsLen; |
| 830 | } |
| 831 | |
| 832 | this._requests[reqid] = { cb }; |
| 833 | |
| 834 | const isBuffered = sendOrBuffer(this, buf); |
| 835 | this._debug && this._debug( |
| 836 | `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} MKDIR` |
| 837 | ); |
| 838 | } |
| 839 | rmdir(path, cb) { |
| 840 | if (this.server) |
| 841 | throw new Error('Client-only method called in server mode'); |
no test coverage detected