MCPcopy
hub / github.com/jvilk/BrowserFS / allocate

Method allocate

src/backend/HTML5FS.ts:235–253  ·  view source on GitHub ↗

* **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)

Source from the content-addressed store, hash-verified

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.

Callers 6

CreateMethod · 0.95
nop.jsFile · 0.80
bad_lookup.jsFile · 0.80
readdir_empty.jsFile · 0.80
readdir.jsFile · 0.80
files.jsFile · 0.80

Calls 1

_requestQuotaFunction · 0.85

Tested by

no test coverage detected