The module allows you to access files and directories on the Flipper Zero filesystems. Call the require
function to load the module before first using its methods:
To work with files and folders, you'll need to specify paths to them. File paths have the following structure:
/int/
(small storage in the MCU's flash memory) or /ext/
(microSD card storage). Specify the sub-directories containing the file using /
as a separator between directory names.Filesystem information structure.
Fields
File information structure.
Fields
stat
) or file name (e.g. "test", returned by readDirectory
)true
if path leads to a directory (not a file)This class implements methods for working with file. To get an object of the File class, use the openFile
method.
Closes the file. After this method is called, all other operations related to this file become unavailable.
Returns
true
on success, false
on failure.
Returns
true
if file is currently opened, false
otherwise.
Reads bytes from a file opened in read-only or read-write mode.
Parameters
string
decoded from ASCII data ("ascii"
), or an ArrayBuf
("binary"
)Returns
An ArrayBuf
if the mode is "binary"
, a string
if the mode is ascii
. The number of bytes that was actually read may be fewer than requested.
Writes bytes to a file opened in write-only or read-write mode.
Parameters
Returns
The amount of bytes that was actually written.
Moves the R/W pointer forward.
Parameters
Returns
true
on success, false
on failure.
Moves the R/W pointer to an absolute position inside the file.
Parameters
Returns
true
on success, false
on failure.
Gets the absolute position of the R/W pointer in bytes.
Returns
The absolute current position in the file.
Discards the data after the current position of the R/W pointer in a file opened in either write-only or read-write mode.
Returns
true
on success, false
on failure.
Returns
The total size of the file in bytes.
Detects whether the R/W pointer has reached the end of the file.
Returns
true
if end of file reached, false
otherwise.
Copies bytes from the R/W pointer in the current file to the R/W pointer in another file.
Parameters
Returns
true
on success, false
on failure.
Opens a file.
Parameters
"r"
, "w"
or "rw"
)"open_existing"
, "open_always"
, "open_append"
, "create_new"
or "create_always"
)Returns
A File
object on success, undefined
otherwise.
Detects whether a file exists.
Parameters
Returns
true
if file exists, false
otherwise.
Determines whether the two paths are equivalent. Respects filesystem-defined path equivalence rules.
Parameters
Returns
true
if path1 and path2 are equals, false
otherwise.
Determines whether a path is a subpath of another path. Respects filesystem-defined path equivalence rules.
Parameters
Returns
true
if path1 and path2 are equals, false
otherwise.
Detects whether a file or a directory exists.
Parameters
Returns
true
if file/directory exists, false
otherwise.
Example
Fetches generic information about a filesystem.
Parameters
"/ext"
or "/int"
)Returns
A fsInfo
structure or undefined
on failure.
Example
Acquires metadata about a file or directory.
Parameters
Returns
A FileInfo
structure or undefined
on failure.
Example
Detects whether a directory exists.
Parameters
Returns
true
if directory exists, false
otherwise.
Creates an empty directory.
Parameters
Returns
true
on success, false
on failure.
Reads the list of files in a directory.
Parameters
Returns
Array of FileInfo
structures with directory entries, or undefined
on failure.
Chooses the next available filename with a numeric suffix in a directory.
Parameters
Returns
The base of the filename with the next available numeric suffix, without the extension or the base directory.
Copies a file or recursively copies a possibly non-empty directory.
Parameters
Returns
true
on success, false
on failure.
Example
Renames or moves a file or directory.
Parameters
Returns
true
on success, false
on failure.
Example
Removes a file or an empty directory.
Parameters
Returns
true
on success, false
on failure.
Example
Removes a file or recursively removes a possibly non-empty directory.
Parameters
Returns
true
on success, false
on failure.
Example