import * as nodeFs from 'node:fs'; import { createRequire } from 'node:module'; const require = createRequire(import.meta.url); let cached: typeof nodeFs | null = null; /** * Return Node's unpatched fs module inside Electron. * * Electron patches `node:fs` to treat any `.asar` file anywhere on disk as a virtual archive * directory, which breaks streaming reads, stats and recursive cleanup when copying or managing * player folders that happen to contain an `.asar` file. Falls back to `node:fs` outside Electron. */ export function rawFs(): typeof nodeFs { if (cached) return cached; try { cached = require('original-fs') as typeof nodeFs; } catch { cached = nodeFs; } return cached; }