import * as file from "ext:file/sync.js"; import * as stdio from "ext:stdio/sync.js"; import type { DirEntry, FileInfo, OpenOptions } from "avril:std"; export type { DirEntry, FileInfo, OpenOptions } from "avril:std"; export type FileHandle = import("avril:std").FileHandle; export const errors: typeof import("avril:std").errors = file.errors; export const FileHandle: typeof import("avril:std").FileHandle = file.FileHandle; export const SeekMode: typeof import("avril:std").SeekMode = file.SeekMode; /** Blocking stdin. Overlapping native reads throw Busy; canceling the async stream also closes this input. Unavailable in the REPL and workers. */ export const stdin: Readonly<{ read(buffer: Uint8Array): number | null; }> = stdio.stdin; /** Blocking output, ordered with already-submitted stream and console writes. Does not run JS callbacks while waiting. */ export const stdout: Readonly<{ write(bytes: Uint8Array): number; }> = stdio.stdout; export const stderr: Readonly<{ write(bytes: Uint8Array): number; }> = stdio.stderr; export const open: ( path: string | URL, options?: OpenOptions, ) => FileHandle = file.open; export const create: (path: string | URL) => FileHandle = file.create; export const stat: (path: string | URL) => FileInfo = file.stat; export const lstat: (path: string | URL) => FileInfo = file.lstat; export const readDir: (path: string | URL) => Iterable = file.readDir; export const mkdir: ( path: string | URL, options?: { mode?: number }, ) => void = file.mkdir; export const remove: ( path: string | URL, options?: { recursive?: boolean }, ) => void = file.remove; /** Requires directory-shaped authority over the source (read/write) and destination (write). Scoped directory renames containing symlinks are not yet implemented. */ export const rename: ( source: string | URL, destination: string | URL, ) => void = file.rename; export const copyFile: ( source: string | URL, destination: string | URL, ) => void = file.copyFile; /** Stores target text unchanged; requires write at the link and read/write tree authority over its target. Creation on Windows is not yet implemented. */ export const symlink: ( target: string | URL, linkPath: string | URL, options?: { type?: "file" | "dir" }, ) => void = file.symlink; /** Reads the link's stored text, not its referent. */ export const readLink: (path: string | URL) => string = file.readLink; export const realPath: (path: string | URL) => string = file.realPath; /** Changes the file mode bits. Follows links. */ export const chmod: (path: string | URL, mode: number) => void = file.chmod; /** Null keeps that id; 4294967295 is rejected. Follows links. */ export const chown: ( path: string | URL, uid: number | null, gid: number | null, ) => void = file.chown; /** Like chown but acts on the link itself. */ export const lchown: ( path: string | URL, uid: number | null, gid: number | null, ) => void = file.lchown; /** Times are seconds since the Unix epoch, like Deno and Node; Dates are accepted. Follows links. */ export const utime: ( path: string | URL, atime: number | Date, mtime: number | Date, ) => void = file.utime; /** Like utime but acts on the link itself; a trailing slash follows instead. */ export const lutime: ( path: string | URL, atime: number | Date, mtime: number | Date, ) => void = file.lutime; /** Requires read and write authority over the source and write over the destination; symlink sources are refused. */ export const link: ( oldpath: string | URL, newpath: string | URL, ) => void = file.link; /** Sets the file size, zero-filling growth. Follows links. */ export const truncate: (path: string | URL, length?: number) => void = file.truncate;