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

Method getDirListing

src/generic/key_value_filesystem.ts:1085–1102  ·  view source on GitHub ↗

* Given the Inode of a directory, retrieves the corresponding directory * listing.

(tx: AsyncKeyValueROTransaction, p: string, inode: Inode, cb: BFSCallback<{ [fileName: string]: string }>)

Source from the content-addressed store, hash-verified

1083 * listing.
1084 */
1085 private getDirListing(tx: AsyncKeyValueROTransaction, p: string, inode: Inode, cb: BFSCallback<{ [fileName: string]: string }>): void {
1086 if (!inode.isDirectory()) {
1087 cb(ApiError.ENOTDIR(p));
1088 } else {
1089 tx.get(inode.id, (e: ApiError, data?: Buffer): void => {
1090 if (noError(e, cb)) {
1091 try {
1092 cb(null, JSON.parse(data!.toString()));
1093 } catch (e) {
1094 // Occurs when data is undefined, or corresponds to something other
1095 // than a directory listing. The latter should never occur unless
1096 // the file system is corrupted.
1097 cb(ApiError.ENOENT(p));
1098 }
1099 }
1100 });
1101 }
1102 }
1103
1104 /**
1105 * Given a path to a directory, retrieves the corresponding INode and

Callers 3

readdirMethod · 0.95
_findINodeMethod · 0.95

Calls 7

cbFunction · 0.85
noErrorFunction · 0.85
ENOTDIRMethod · 0.80
toStringMethod · 0.80
ENOENTMethod · 0.80
getMethod · 0.65
isDirectoryMethod · 0.45

Tested by

no test coverage detected