* Given the Inode of a directory, retrieves the corresponding directory * listing.
(tx: AsyncKeyValueROTransaction, p: string, inode: Inode, cb: BFSCallback<{ [fileName: string]: string }>)
| 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 |