in packages/web-ide-fs/src/browserfs/OverlayFSImpl.ts [275:300]
async stat(p: string, isLstat: boolean | null): Promise<Stats> {
// Original impl https://github.com/jvilk/BrowserFS/blob/v1.4.3/src/backend/OverlayFS.ts#L350
// See "Read Strategy" in class description
try {
const writableStat = await this.#writable.stat(p, isLstat);
return writableStat;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (e: any) {
// ENOENT is the only expected possible error. So if we got something else, let's panic.
if (e?.errno !== ErrorCode.ENOENT) {
throw e;
}
}
// Otherwise, let's check out readable
if (!(await this.#existsInReadable(p))) {
throw ApiError.ENOENT(p);
}
const readableStat = await this.#readable.stat(p, isLstat);
const stat = readableStat.clone();
stat.mode = makeModeWritable(stat.mode);
return stat;
}