@opfs.js/core
    Preparing search index...

    Interface FileSystemSyncAccessHandle

    Represents a synchronous access file handle that provides high-performance read/write operations.

    interface FileSystemSyncAccessHandle {
        close(): void;
        flush(): void;
        getSize(): number;
        read(buffer: BufferSource, options?: { at?: number }): number;
        truncate(newSize: number): void;
        write(buffer: BufferSource, options?: { at?: number }): number;
    }
    Index

    Methods

    • Close the handle and release lock resources.

      Returns void

      void

    • Persist the contents of the write buffer to storage.

      Returns void

      void

      InvalidStateError If the access handle is already closed

    • Get the byte size of the file.

      Returns number

      File byte size

      InvalidStateError If the access handle is already closed

    • Read content from the file into the specified buffer.

      Parameters

      • buffer: BufferSource

        Buffer for storing data (BufferSource, such as Uint8Array, DataView, etc.). Note: Cannot directly operate on ArrayBuffer, should access through typed arrays.

      • Optionaloptions: { at?: number }

        Optional object:

        • at: number, start reading from the specified byte offset in the file

      Returns number

      Number of bytes actually read

      InvalidStateError If the access handle is already closed

      TypeError If the underlying file system does not support reading from the specified offset

    • Truncate or extend the file to the specified size.

      Parameters

      • newSize: number

        Adjusted byte size of the file

      Returns void

      void

      InvalidStateError If the access handle is already closed or file modification fails

      QuotaExceededError If newSize exceeds browser storage quota

      TypeError If the underlying file system does not support adjusting file size

    • Write data from the specified buffer to the file.

      Parameters

      • buffer: BufferSource

        Data to be written to the file (BufferSource, such as Uint8Array, DataView, etc.)

      • Optionaloptions: { at?: number }

        Optional object:

        • at: number, start writing from the specified byte offset in the file

      Returns number

      Number of bytes actually written

      InvalidStateError If the access handle is already closed or file data modification fails

      QuotaExceededError If writing exceeds browser storage quota

      TypeError If the underlying file system does not support writing to the specified offset