pure
    Preparing search index...

    Interface FsFile

    Interface for operating on a file in the loaded file system

    interface FsFile {
        path: string;
        close(): void;
        getBytes(): Promise<FsResult<Uint8Array<ArrayBufferLike>>>;
        getLastModified(): Promise<FsResult<number>>;
        getText(): Promise<FsResult<string>>;
        isDirty(): boolean;
        load(): Promise<FsVoid>;
        loadIfNotDirty(): Promise<FsVoid>;
        setBytes(content: Uint8Array): void;
        setText(content: string): void;
        writeIfNewer(): Promise<FsVoid>;
    }
    Index

    Properties

    path: string

    Path of the file relative to the root of the file system (the uploaded directory)

    Methods

    • Close the file. In memory content will be lost. Further operations on the file will fail

      Returns void

    • Get the content of the file

      Returns Promise<FsResult<Uint8Array<ArrayBufferLike>>>

    • Get the last modified time. May load it from file system if needed

      Returns Promise<FsResult<number>>

    • Get the text content of the file

      If the file is not loaded, it will load it.

      If the file is not a text file, it will return InvalidEncoding

      Returns Promise<FsResult<string>>

    • Returns if the content of the file in memory is newer than the file on disk

      Returns boolean

    • Load the file's content from FS.

      Overwrites any unsaved changes in memory only if the file was modified at a later time than the last in memory modification.

      If it fails, the file's content in memory will not be changed

      Returns Promise<FsVoid>

    • Load the file's content if it's not newer than fs

      Returns Ok if the file is newer than fs

      Returns Promise<FsVoid>

    • Set the content in memory. Does not save to disk. Does nothing if file is closed

      Parameters

      • content: Uint8Array

      Returns void

    • Set the content in memory. Does not save to disk. Does nothing if file is closed

      Parameters

      • content: string

      Returns void

    • Save the file's content to FS if it is dirty.

      If not dirty, returns Ok

      Returns Promise<FsVoid>