API Documentation¶
littlefs module¶
-
class
littlefs.
LittleFS
(context: UserContext = None, **kwargs)¶ Littlefs file system
-
context
¶ User context of the file system
-
format
() → int¶ Format the underlying buffer
-
listdir
(path='.') → List[str]¶ List directory content
List the content of a directory. This function uses
scandir()
internally. Usingscandir()
might be better if you are searching for a specific file or need access to thelittlefs.lfs.LFSStat
of the files.
-
makedirs
(name: str, exist_ok=False)¶ Recursive directory creation function.
-
mkdir
(path: str) → int¶ Create a new directory
-
mount
() → int¶ Mount the underlying buffer
-
open
(fname: str, mode='r') → littlefs.FileHandle¶ Open a file
-
remove
(path: str) → int¶ Remove a file or directory
If the path to remove is a directory, the directory must be empty.
Parameters: path (str) – The path to the file or directory to remove.
-
removedirs
(name)¶ Remove directories recursively
This works like
remove()
but if the leaf directory is empty after the successfull removal ofname
, the function tries to recursively remove all parent directories which are also empty.
-
rename
(src: str, dst: str) → int¶ Rename a file or directory
-
scandir
(path='.') → Iterator[LFSStat]¶ List directory content
-
stat
(path: str) → LFSStat¶ Get the status of a file or directory
-
walk
(top: str) → Iterator[Tuple[str, List[str], List[str]]]¶ Generate the file names in a directory tree
Generate the file and directory names in a directory tree by walking the tree top-down. This functions closely resembels the behaviour of
os.stat()
.Each iteration yields a tuple containing three elements:
- The root of the currently processed element
- A list of filenames located in the root
- A list of directorys located in the root
-
littlefs.context module¶
-
class
littlefs.context.
UserContext
(buffsize: int)¶ Basic User Context Implementation
-
erase
(cfg: LFSConfig, block: int) → int¶ Erase a block
Parameters:
-
prog
(cfg: LFSConfig, block: int, off: int, data: bytes) → int¶ program data
Parameters:
-
read
(cfg: LFSConfig, block: int, off: int, size: int) → bytearray¶ read data
Parameters:
-
littlefs.lfs module¶
-
class
littlefs.lfs.
LFSStat
¶ Littlefs File / Directory status
-
name
¶ Alias for field number 2
-
size
¶ Alias for field number 1
-
type
¶ Alias for field number 0
-
-
class
littlefs.lfs.
LFSConfig
(context=None, **kwargs)¶ -
block_count
¶
-
block_size
¶
-
cache_size
¶
-
lookahead_size
¶
-
prog_size
¶
-
read_size
¶
-
-
class
littlefs.lfs.
LFSDirectory
¶
-
class
littlefs.lfs.
LFSFile
¶
-
class
littlefs.lfs.
LFSFilesystem
¶
-
littlefs.lfs.
dir_close
(LFSFilesystem fs, LFSDirectory dh)¶
-
littlefs.lfs.
dir_open
(LFSFilesystem fs, path)¶
-
littlefs.lfs.
dir_read
(LFSFilesystem fs, LFSDirectory dh)¶
-
littlefs.lfs.
dir_rewind
(LFSFilesystem fs, LFSDirectory dh)¶
-
littlefs.lfs.
dir_tell
(LFSFilesystem fs, LFSDirectory dh)¶
-
littlefs.lfs.
file_close
(LFSFilesystem fs, LFSFile fh)¶
-
littlefs.lfs.
file_open
(LFSFilesystem fs, path, flags)¶
-
littlefs.lfs.
file_open_cfg
(self, path, flags, config)¶
-
littlefs.lfs.
file_read
(LFSFilesystem fs, LFSFile fh, size)¶
-
littlefs.lfs.
file_rewind
(LFSFilesystem fs, LFSFile fh)¶
-
littlefs.lfs.
file_seek
(LFSFilesystem fs, LFSFile fh, off, whence)¶
-
littlefs.lfs.
file_size
(LFSFilesystem fs, LFSFile fh)¶
-
littlefs.lfs.
file_sync
(LFSFilesystem fs, LFSFile fh)¶
-
littlefs.lfs.
file_tell
(LFSFilesystem fs, LFSFile fh)¶
-
littlefs.lfs.
file_truncate
(LFSFilesystem fs, LFSFile fh, size)¶
-
littlefs.lfs.
file_write
(LFSFilesystem fs, LFSFile fh, data)¶
-
littlefs.lfs.
format
(LFSFilesystem fs, LFSConfig cfg)¶ Format the filesystem
-
littlefs.lfs.
fs_size
(LFSFilesystem fs)¶
-
littlefs.lfs.
getattr
(LFSFilesystem fs, path, type, buffer, size)¶
-
littlefs.lfs.
mkdir
(LFSFilesystem fs, path)¶
-
littlefs.lfs.
mount
(LFSFilesystem fs, LFSConfig cfg)¶ Mount the filesystem
-
littlefs.lfs.
remove
(LFSFilesystem fs, path)¶ Remove a file or directory
If removing a direcotry, the directory must be empty.
-
littlefs.lfs.
removeattr
(LFSFilesystem fs, path, type)¶
-
littlefs.lfs.
rename
(LFSFilesystem fs, oldpath, newpath)¶ Rename or move a file or directory
If the destination exists, it must match the source in type. If the destination is a directory, the directory must be empty.
-
littlefs.lfs.
setattr
(LFSFilesystem fs, path, type, buffer, size)¶
-
littlefs.lfs.
stat
(LFSFilesystem fs, path)¶ Find info about a file or directory
-
littlefs.lfs.
unmount
(LFSFilesystem fs)¶ Unmount the filesystem
This does nothing beside releasing any allocated resources