Helia
    Preparing search index...

    Interface MFS

    The MFS interface allows working with files and directories in a mutable file system.

    interface MFS {
        cat(
            path: string,
            options?: Partial<CatOptions>,
        ): AsyncIterable<Uint8Array<ArrayBufferLike>>;
        chmod(
            path: string,
            mode: number,
            options?: Partial<ChmodOptions>,
        ): Promise<void>;
        cp(
            source: string | CID<unknown, number, number, Version>,
            destination: string,
            options?: Partial<CpOptions>,
        ): Promise<void>;
        ls(path?: string, options?: Partial<LsOptions>): AsyncIterable<UnixFSEntry>;
        mkdir(path: string, options?: Partial<MkdirOptions>): Promise<void>;
        rm(path: string, options?: Partial<RmOptions>): Promise<void>;
        stat(
            path: string,
            options?: StatOptions,
        ): Promise<FileStats | DirectoryStats | RawStats>;
        stat(
            path: string,
            options?: ExtendedStatOptions,
        ): Promise<ExtendedFileStats | ExtendedDirectoryStats | ExtendedRawStats>;
        touch(path: string, options?: Partial<TouchOptions>): Promise<void>;
        writeBytes(
            bytes: Uint8Array,
            path: string,
            options?: Partial<WriteOptions>,
        ): Promise<void>;
        writeByteStream(
            bytes: ByteStream,
            path: string,
            options?: Partial<WriteOptions>,
        ): Promise<void>;
    }
    Index

    Methods

    • Change the permissions on a file or directory in your MFS

      Parameters

      Returns Promise<void>

      await fs.writeBytes(Uint8Array.from([0, 1, 2, 3]), '/foo.txt')
      const beforeStats = await fs.stat('/foo.txt')

      await fs.chmod('/foo.txt', 0x755)
      const afterStats = await fs.stat('/foo.txt')

      console.info(beforeStats)
      console.info(afterStats)
    • Add a file or directory to a target directory in your MFS.

      Parameters

      Returns Promise<void>

      await fs.writeBytes(Uint8Array.from([0, 1, 2, 3]), '/foo.txt')
      await fs.mkdir('/bar')

      await fs.cp('/foo.txt', '/bar')

      Copy a file from one place to another in your MFS.

      await fs.writeBytes(Uint8Array.from([0, 1, 2, 3]), '/foo.txt')

      await fs.cp('/foo.txt', '/bar.txt')
    • Update the mtime of a UnixFS DAG in your MFS.

      Parameters

      Returns Promise<void>

      await fs.writeBytes(Uint8Array.from([0, 1, 2, 3]), '/foo.txt')
      const beforeStats = await fs.stat('/foo.txt')

      await fs.touch('/foo.txt')
      const afterStats = await fs.stat(afterCid)

      console.info(beforeStats)
      console.info(afterStats)