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

Method preloadFile

src/backend/XmlHttpRequest.ts:197–209  ·  view source on GitHub ↗

* Special XHR function: Preload the given file into the index. * @param [String] path * @param [BrowserFS.Buffer] buffer

(path: string, buffer: Buffer)

Source from the content-addressed store, hash-verified

195 * @param [BrowserFS.Buffer] buffer
196 */
197 public preloadFile(path: string, buffer: Buffer): void {
198 const inode = this._index.getInode(path);
199 if (isFileInode<Stats>(inode)) {
200 if (inode === null) {
201 throw ApiError.ENOENT(path);
202 }
203 const stats = inode.getData();
204 stats.size = buffer.length;
205 stats.fileData = buffer;
206 } else {
207 throw ApiError.EISDIR(path);
208 }
209 }
210
211 public stat(path: string, isLstat: boolean, cb: BFSCallback<Stats>): void {
212 const inode = this._index.getInode(path);

Callers

nothing calls this directly

Calls 5

isFileInodeFunction · 0.90
getInodeMethod · 0.80
ENOENTMethod · 0.80
EISDIRMethod · 0.80
getDataMethod · 0.45

Tested by

no test coverage detected