import * as fsp from 'node:fs/promises' export async function fileExists(path: string): Promise { try { const stat = await fsp.stat(path) return stat.isFile() } catch { return false } } export async function directoryExists(path: string): Promise { try { const stat = await fsp.stat(path) return stat.isDirectory() } catch { return false } } export function sanitizeFilename(filename: string) { return filename.replace(/[/\\?%*:|"<>]/g, '_') }