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

Method readdirSync

src/backend/MountableFileSystem.ts:247–279  ·  view source on GitHub ↗
(p: string)

Source from the content-addressed store, hash-verified

245 }
246
247 public readdirSync(p: string): string[] {
248 const fsInfo = this._getFs(p);
249
250 // If null, rootfs did not have the directory
251 // (or the target FS is the root fs).
252 let rv: string[] | null = null;
253 // Mount points are all defined in the root FS.
254 // Ensure that we list those, too.
255 if (fsInfo.fs !== this.rootFs) {
256 try {
257 rv = this.rootFs.readdirSync(p);
258 } catch (e) {
259 // Ignore.
260 }
261 }
262
263 try {
264 const rv2 = fsInfo.fs.readdirSync(fsInfo.path);
265 if (rv === null) {
266 return rv2;
267 } else {
268 // Filter out duplicates.
269 return rv2.concat(rv.filter((val) => rv2.indexOf(val) === -1));
270 }
271 } catch (e) {
272 if (rv === null) {
273 throw this.standardizeError(e, fsInfo.path, p);
274 } else {
275 // The root FS had something.
276 return rv;
277 }
278 }
279 }
280
281 public readdir(p: string, cb: BFSCallback<string[]>): void {
282 const fsInfo = this._getFs(p);

Callers

nothing calls this directly

Calls 3

_getFsMethod · 0.95
standardizeErrorMethod · 0.95
readdirSyncMethod · 0.65

Tested by

no test coverage detected