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

Method readdir

src/backend/MountableFileSystem.ts:281–306  ·  view source on GitHub ↗
(p: string, cb: BFSCallback<string[]>)

Source from the content-addressed store, hash-verified

279 }
280
281 public readdir(p: string, cb: BFSCallback<string[]>): void {
282 const fsInfo = this._getFs(p);
283 fsInfo.fs.readdir(fsInfo.path, (err, files) => {
284 if (fsInfo.fs !== this.rootFs) {
285 try {
286 const rv = this.rootFs.readdirSync(p);
287 if (files) {
288 // Filter out duplicates.
289 files = files.concat(rv.filter((val) => files!.indexOf(val) === -1));
290 } else {
291 files = rv;
292 }
293 } catch (e) {
294 // Root FS and target FS did not have directory.
295 if (err) {
296 return cb(this.standardizeError(err, fsInfo.path, p));
297 }
298 }
299 } else if (err) {
300 // Root FS and target FS are the same, and did not have directory.
301 return cb(this.standardizeError(err, fsInfo.path, p));
302 }
303
304 cb(null, files);
305 });
306 }
307
308 public rmdirSync(p: string): void {
309 const fsInfo = this._getFs(p);

Callers

nothing calls this directly

Calls 5

_getFsMethod · 0.95
standardizeErrorMethod · 0.95
cbFunction · 0.85
readdirMethod · 0.65
readdirSyncMethod · 0.65

Tested by

no test coverage detected