MCPcopy Index your code
hub / github.com/jvilk/BrowserFS / openFile

Method openFile

src/generic/key_value_filesystem.ts:889–906  ·  view source on GitHub ↗
(p: string, flag: FileFlag, cb: BFSCallback<File>)

Source from the content-addressed store, hash-verified

887 }
888
889 public openFile(p: string, flag: FileFlag, cb: BFSCallback<File>): void {
890 const tx = this.store.beginTransaction('readonly');
891 // Step 1: Grab the file's inode.
892 this.findINode(tx, p, (e: ApiError, inode?: Inode) => {
893 if (noError(e, cb)) {
894 // Step 2: Grab the file's data.
895 tx.get(inode!.id, (e: ApiError, data?: Buffer): void => {
896 if (noError(e, cb)) {
897 if (data === undefined) {
898 cb(ApiError.ENOENT(p));
899 } else {
900 cb(null, new AsyncKeyValueFile(this, p, flag, inode!.toStats(), data));
901 }
902 }
903 });
904 }
905 });
906 }
907
908 public unlink(p: string, cb: BFSOneArgCallback): void {
909 this.removeEntry(p, false, cb);

Callers

nothing calls this directly

Calls 7

findINodeMethod · 0.95
noErrorFunction · 0.85
cbFunction · 0.85
ENOENTMethod · 0.80
toStatsMethod · 0.80
beginTransactionMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected