| 421 | } |
| 422 | |
| 423 | public empty(mainCb: BFSOneArgCallback): void { |
| 424 | this._client.readdir('/', (error, files) => { |
| 425 | if (error) { |
| 426 | mainCb(this.convert(error, '/')); |
| 427 | } else { |
| 428 | const deleteFile = (file: string, cb: BFSOneArgCallback) => { |
| 429 | const p = path.join('/', file); |
| 430 | this._client.remove(p, (err) => { |
| 431 | cb(err ? this.convert(err, p) : null); |
| 432 | }); |
| 433 | }; |
| 434 | const finished = (err?: ApiError) => { |
| 435 | if (err) { |
| 436 | mainCb(err); |
| 437 | } else { |
| 438 | mainCb(); |
| 439 | } |
| 440 | }; |
| 441 | // XXX: <any> typing is to get around overly-restrictive ErrorCallback typing. |
| 442 | asyncEach(files!, <any> deleteFile, <any> finished); |
| 443 | } |
| 444 | }); |
| 445 | } |
| 446 | |
| 447 | public rename(oldPath: string, newPath: string, cb: BFSOneArgCallback): void { |
| 448 | this._client.move(oldPath, newPath, (error) => { |