(cb: BFSOneArgCallback)
| 115 | } |
| 116 | |
| 117 | public sync(cb: BFSOneArgCallback): void { |
| 118 | if (!this.isDirty()) { |
| 119 | return cb(); |
| 120 | } |
| 121 | |
| 122 | this._entry.createWriter((writer) => { |
| 123 | const buffer = this.getBuffer(); |
| 124 | const blob = new Blob([buffer2ArrayBuffer(buffer)]); |
| 125 | const length = blob.size; |
| 126 | writer.onwriteend = (err?: any) => { |
| 127 | writer.onwriteend = <any> null; |
| 128 | writer.onerror = <any> null; |
| 129 | writer.truncate(length); |
| 130 | this.resetDirty(); |
| 131 | cb(); |
| 132 | }; |
| 133 | writer.onerror = (err: any) => { |
| 134 | cb(convertError(err, this.getPath(), false)); |
| 135 | }; |
| 136 | writer.write(blob); |
| 137 | }); |
| 138 | } |
| 139 | |
| 140 | public close(cb: BFSOneArgCallback): void { |
| 141 | this.sync(cb); |
no test coverage detected