import { type IPitcherClient } from "@codesandbox/pitcher-client";
import { Disposable } from "../../utils/disposable";
import { type Event } from "../../utils/event";
export type FSStatResult = {
    type: "file" | "directory";
    isSymlink: boolean;
    size: number;
    mtime: number;
    ctime: number;
    atime: number;
};
export type WriteFileOpts = {
    create?: boolean;
    overwrite?: boolean;
};
export type ReaddirEntry = {
    name: string;
    type: "file" | "directory";
    isSymlink: boolean;
};
export type WatchOpts = {
    readonly recursive?: boolean;
    readonly excludes?: readonly string[];
};
export type WatchEvent = {
    paths: string[];
    type: "add" | "change" | "remove";
};
export type Watcher = {
    dispose(): void;
    onEvent: Event<WatchEvent>;
};
export declare class FileSystem {
    private pitcherClient;
    private username?;
    private disposable;
    constructor(sessionDisposable: Disposable, pitcherClient: IPitcherClient, username?: string | undefined);
    /**
     * Write a file.
     */
    writeFile(path: string, content: Uint8Array, opts?: WriteFileOpts): Promise<void>;
    /**
     * Write a file as a string.
     */
    writeTextFile(path: string, content: string, opts?: WriteFileOpts): Promise<void>;
    /**
     * Create a directory.
     */
    mkdir(path: string, recursive?: boolean): Promise<void>;
    /**
     * Read a directory.
     */
    readdir(path: string): Promise<ReaddirEntry[]>;
    /**
     * Read a file
     */
    readFile(path: string): Promise<Uint8Array>;
    /**
     * Read a file as a string.
     */
    readTextFile(path: string): Promise<string>;
    /**
     * Get the stat of a file or directory.
     */
    stat(path: string): Promise<FSStatResult>;
    /**
     * Copy a file or directory.
     */
    copy(from: string, to: string, recursive?: boolean, overwrite?: boolean): Promise<void>;
    /**
     * Rename a file or directory.
     */
    rename(from: string, to: string, overwrite?: boolean): Promise<void>;
    /**
     * Remove a file or directory.
     */
    remove(path: string, recursive?: boolean): Promise<void>;
    /**
     * Watch for changes in the filesystem.
     *
     * ```ts
     * const watcher = await sandbox.fs.watch("/path/to/watch");
     * watcher.onEvent((event) => {
     *   console.log(event);
     * });
     *
     * // When done
     * watcher.dispose();
     * ```
     *
     * @param path - The path to watch.
     * @param options - The options for the watch.
     * @returns A watcher that can be disposed to stop the watch.
     */
    watch(path: string, options?: WatchOpts): Promise<Watcher>;
    /**
     * Download a file or folder from the filesystem, can only be used to download
     * from within the workspace directory. A download URL that's valid for 5 minutes.
     */
    download(path: string): Promise<{
        downloadUrl: string;
    }>;
}
