* **Deprecated. Please use Create() method instead to create and allocate an HTML5FS.** * * Requests a storage quota from the browser to back this FS. * Must be called before file system can be used!
(cb: BFSOneArgCallback = () => {/*nop*/}, deprecateMsg = true)
| 233 | * Must be called before file system can be used! |
| 234 | */ |
| 235 | public allocate(cb: BFSOneArgCallback = () => {/*nop*/}, deprecateMsg = true): void { |
| 236 | if (deprecateMsg) { |
| 237 | console.warn(`[HTML5FS] HTML5FS.allocate() is deprecated and will be removed in the next major release. Please use 'HTML5FS.Create({type: ${this.type}, size: ${this.size}}, cb)' to create and allocate HTML5FS instances.`); |
| 238 | } |
| 239 | const success = (fs: FileSystem): void => { |
| 240 | this.fs = fs; |
| 241 | cb(); |
| 242 | }; |
| 243 | const error = (err: DOMException): void => { |
| 244 | cb(convertError(err, "/", true)); |
| 245 | }; |
| 246 | if (this.type === global.PERSISTENT) { |
| 247 | _requestQuota(this.type, this.size, (granted: number) => { |
| 248 | _getFS(this.type, granted, success, error); |
| 249 | }, error); |
| 250 | } else { |
| 251 | _getFS(this.type, this.size, success, error); |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | /** |
| 256 | * Deletes everything in the FS. Used for testing. |
no test coverage detected