Angular Modernizer
    Preparing search index...

    Core abstraction for file system operations.

    All operations are asynchronous. The implementations (RealFileSystemAdapter, InMemoryFileSystemAdapter) add synchronous variants for ts-morph FileSystemHost compatibility, and the in-memory variant lets tests run without disk access.

    interface FileSystemAdapter {
        createDirectory(path: string): Promise<void>;
        deleteFile(path: string): Promise<void>;
        directoryExists(path: string): Promise<boolean>;
        exists(path: string): Promise<boolean>;
        fileExists(path: string): Promise<boolean>;
        getFileStats(path: string): Promise<{ mtime: number; size: number }>;
        readDirectory(path: string): Promise<string[]>;
        readFile(path: string): Promise<string>;
        writeFile(path: string, content: string): Promise<void>;
    }

    Implemented by

    Index

    Methods

    • Create a directory (and parent directories if needed).

      Parameters

      • path: string

        Directory path to create

      Returns Promise<void>

      Error if directory cannot be created

    • Delete a file.

      Parameters

      • path: string

        Path to the file to delete

      Returns Promise<void>

      Error if file doesn't exist or cannot be deleted

    • Check if a path points to a directory.

      Parameters

      • path: string

        Path to check

      Returns Promise<boolean>

      Promise resolving to true if path is a directory, false otherwise

    • Check if a file or directory exists.

      Parameters

      • path: string

        Path to check

      Returns Promise<boolean>

      Promise resolving to true if exists, false otherwise

    • Check if a path points to a file (not a directory).

      Parameters

      • path: string

        Path to check

      Returns Promise<boolean>

      Promise resolving to true if path is a file, false otherwise

    • Get file statistics.

      Parameters

      • path: string

        File path

      Returns Promise<{ mtime: number; size: number }>

      Promise resolving to file stats with mtime and size

      Error if file doesn't exist

    • List all files in a directory (non-recursive).

      Parameters

      • path: string

        Directory path

      Returns Promise<string[]>

      Promise resolving to array of file/directory names

      Error if directory doesn't exist or cannot be read

    • Read a file's contents as a UTF-8 string.

      Parameters

      • path: string

        Absolute or relative path to the file

      Returns Promise<string>

      Promise resolving to file contents

      Error if file doesn't exist or cannot be read

    • Write content to a file, creating directories if needed.

      Parameters

      • path: string

        Absolute or relative path to the file

      • content: string

        String content to write

      Returns Promise<void>

      Error if write operation fails