* List directory or get file info * @param {String} filename * @param {boolean} stat
(filename = this.#path)
| 61 | * @param {boolean} stat |
| 62 | */ |
| 63 | lsDir(filename = this.#path) { |
| 64 | return new Promise((resolve, reject) => { |
| 65 | sftp.isConnected(async (connectionID) => { |
| 66 | (async () => { |
| 67 | if (this.#notConnected(connectionID)) { |
| 68 | try { |
| 69 | await this.connect(); |
| 70 | } catch (error) { |
| 71 | reject(error); |
| 72 | return; |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | const path = this.#safeName(filename); |
| 77 | |
| 78 | sftp.lsDir( |
| 79 | path, |
| 80 | (res) => { |
| 81 | res.forEach((file) => { |
| 82 | file.url = Url.join(this.#base, file.url); |
| 83 | file.type = mimeType.lookup(filename); |
| 84 | if (file.isLink) { |
| 85 | file.linkTarget = Url.join(this.#base, file.linkTarget); |
| 86 | } |
| 87 | }); |
| 88 | resolve(res); |
| 89 | }, |
| 90 | (err) => { |
| 91 | reject(err); |
| 92 | }, |
| 93 | ); |
| 94 | })(); |
| 95 | }, reject); |
| 96 | }); |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * |
no test coverage detected