micro:bit filesystem library
    Preparing search index...

    Class MicropythonFsHex

    Manage filesystem files in one or multiple MicroPython hex files.

    Implements

    • FsInterface
    Index
    • File System manager constructor.

      At the moment it needs a MicroPython hex string without files included. Multiple MicroPython images can be provided to generate a Universal Hex.

      Parameters

      • intelHex: string | IntelHexWithId[]

        MicroPython Intel Hex string or an array of Intel Hex strings with their respective board IDs.

      • __namedParameters: { maxFsSize?: number } = {}

      Returns MicropythonFsHex

      When any of the input iHex contains filesystem files.

      When any of the input iHex is not a valid MicroPython hex.

    • Parameters

      • filename: string
      • content: string

      Returns void

    • Create a new file and add it to the file system.

      Parameters

      • filename: string

        Name for the file.

      • content: string | Uint8Array<ArrayBufferLike>

        File content to write.

      Returns void

      When the file already exists.

      When an invalid filename is provided.

      When invalid file data is provided.

    • Check if a file is already present in the file system.

      Parameters

      • filename: string

        Name for the file to check.

      Returns boolean

      True if it exists, false otherwise.

    • Generate a new copy of the MicroPython Intel Hex with the files in the filesystem included.

      Parameters

      • OptionalboardId: number

        When multiple MicroPython hex files are provided select one via this argument.

      Returns string

      A new string with MicroPython and the filesystem included.

      When a file doesn't have any data.

      When there are issues calculating file system boundaries.

      When there is no space left for a file.

      When the board ID is not found.

      When there are multiple MicroPython hexes and board ID is not provided.

    • Generate a byte array of the MicroPython and filesystem data.

      Parameters

      • OptionalboardId: number

        When multiple MicroPython hex files are provided select one via this argument.

      Returns Uint8Array

      A Uint8Array with MicroPython and the filesystem included.

      When a file doesn't have any data.

      When there are issues calculating file system boundaries.

      When there is no space left for a file.

      When the board ID is not found.

      When there are multiple MicroPython hexes and board ID is not provided.

    • The available filesystem total size either calculated by the MicroPython hex or the max storage size limit has been set.

      Returns number

      Size of the filesystem in bytes.

    • Returns number

      The total number of bytes currently used by files in the file system.

    • Generate a new copy of a MicroPython Universal Hex with the files in the filesystem included.

      Returns string

      A new Universal Hex string with MicroPython and filesystem.

      When a file doesn't have any data.

      When there are issues calculating file system boundaries.

      When there is no space left for a file.

      When this method is called without having multiple MicroPython hexes.

    • Read the files included in a MicroPython Universal or Intel Hex string and add them to this instance.

      Parameters

      • hexStr: string

        MicroPython Intel or Universal Hex string with files.

      • options: ImportOptions = {}

      Returns string[]

      A filename list of added files.

      When there are no files to import from the hex.

      When in the Universal Hex the files of the individual hexes are different.

      When there is a problem reading files from one of the hex.

      When a filename already exists in this instance (all other files are still imported).

    • Read the files included in a MicroPython hex string and add them to this instance.

      Parameters

      • intelHex: string

        MicroPython hex string with files.

      • overwrite: ImportOptions = {}

        Flag to overwrite existing files in this instance.

      Returns string[]

      A filename list of added files.

      When there are no files to import in the hex.

      When there is a problem reading the files from the hex.

      When a filename already exists in this instance (all other files are still imported).

    • Read the files included in a MicroPython Universal Hex string and add them to this instance.

      Parameters

      • universalHex: string

        MicroPython Universal Hex string with files.

      • overwrite: ImportOptions = {}

        Flag to overwrite existing files in this instance.

      Returns string[]

      A filename list of added files.

      When there are no files to import from one of the hex.

      When the files in the individual hex are different.

      When there is a problem reading files from one of the hex.

      When a filename already exists in this instance (all other files are still imported).

    • Returns string[]

      A list all the files in the file system.

    • Read the text from a file.

      Parameters

      • filename: string

        Name of the file to read.

      Returns string

      Text from the file.

      When invalid file name is provided.

      When file is not in the file system.

    • Read the bytes from a file.

      Parameters

      • filename: string

        Name of the file to read.

      Returns Uint8Array

      Byte array from the file.

      When invalid file name is provided.

      When file is not in the file system.

    • Delete a file from the file system.

      Parameters

      • filename: string

        Name of the file to delete.

      Returns void

      When invalid file name is provided.

      When the file doesn't exist.

    • Sets a storage size limit. Must be smaller than available space in MicroPython.

      Parameters

      • size: number

        Size in bytes for the filesystem.

      Returns void

    • Returns the size of a file in bytes.

      Parameters

      • filename: string

        Name for the file to check.

      Returns number

      Size file size in bytes.

      When invalid file name is provided.

      When the file doesn't exist.

    • Write a file into the file system. Overwrites a previous file with the same name.

      Parameters

      • filename: string

        Name for the file.

      • content: string | Uint8Array<ArrayBufferLike>

        File content to write.

      Returns void

      When an invalid filename is provided.

      When invalid file data is provided.