Search code examples
filedirectoryfilesystemstoit

File system in Toit


Judging by the lib_v1.0.2 library, access to the file system is implemented in Toit. May be can give some simple examples, which would include:

  1. Create a file,
  2. Writing data to file,
  3. Reading data from a file,
  4. Deleting a file,
  5. Is there support for folders, and if so, what is the nesting level and how to get a list of files in the folder?

Solution

  • Update 2022-12-20: the host package's filesystem functionality (host.file and host.directory) is now supported for sdcards.

    The filesystem libraries are not supported on ESP32 devices. They were implemented for host machines (like Linux), but that version isn't released.

    The libraries will likely move soon and then not be accessible anymore.

    If you want to store data on the device, maybe the device flashstore works for you:

    import device
    
    main:
      store := device.FlashStore
      store.set "key" "data"