littlefs-python 0.17.1__tar.gz → 0.18.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/.github/workflows/deploy.yml +3 -3
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/PKG-INFO +1 -1
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/src/littlefs/__init__.py +41 -17
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/src/littlefs/__main__.py +54 -7
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/src/littlefs/lfs.c +3855 -4171
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/src/littlefs/lfs.pyi +12 -10
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/src/littlefs/lfs.pyx +40 -25
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/src/littlefs_python.egg-info/PKG-INFO +1 -1
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/src/littlefs_python.egg-info/SOURCES.txt +1 -0
- littlefs_python-0.18.0/test/cli/test_create_and_extract.py +193 -0
- littlefs_python-0.18.0/test/test_unicode_filenames.py +101 -0
- littlefs_python-0.17.1/test/cli/test_create_and_extract.py +0 -101
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/.gitattributes +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/.github/dependabot.yml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/.github/workflows/run-tests.yml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/.gitignore +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/.gitmodules +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/.pre-commit-config.yaml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/.readthedocs.yml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/LICENSE +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/MANIFEST.in +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/README.rst +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/ci/build-wheels.sh +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/ci/download_release_files.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/docs/Makefile +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/docs/api/index.rst +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/docs/cli.rst +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/docs/conf.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/docs/doc8.ini +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/docs/examples/index.rst +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/docs/index.rst +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/docs/make.bat +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/docs/requirements.txt +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/docs/usage.rst +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/examples/mkfsimg.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/examples/walk.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/.git +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/.gitattributes +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/.github/workflows/post-release.yml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/.github/workflows/release.yml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/.github/workflows/status.yml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/.github/workflows/test.yml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/.gitignore +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/DESIGN.md +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/LICENSE.md +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/Makefile +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/README.md +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/SPEC.md +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/bd/lfs_emubd.c +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/bd/lfs_emubd.h +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/bd/lfs_filebd.c +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/bd/lfs_filebd.h +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/bd/lfs_rambd.c +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/bd/lfs_rambd.h +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/benches/bench_dir.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/benches/bench_file.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/benches/bench_superblock.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/lfs.c +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/lfs.h +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/lfs_util.c +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/lfs_util.h +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/runners/bench_runner.c +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/runners/bench_runner.h +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/runners/test_runner.c +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/runners/test_runner.h +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/scripts/bench.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/scripts/changeprefix.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/scripts/code.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/scripts/cov.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/scripts/data.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/scripts/perf.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/scripts/perfbd.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/scripts/plot.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/scripts/plotmpl.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/scripts/prettyasserts.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/scripts/readblock.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/scripts/readmdir.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/scripts/readtree.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/scripts/stack.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/scripts/structs.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/scripts/summary.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/scripts/tailpipe.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/scripts/teepipe.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/scripts/test.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/scripts/tracebd.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/scripts/watch.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/tests/test_alloc.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/tests/test_attrs.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/tests/test_badblocks.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/tests/test_bd.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/tests/test_compat.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/tests/test_dirs.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/tests/test_entries.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/tests/test_evil.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/tests/test_exhaustion.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/tests/test_files.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/tests/test_interspersed.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/tests/test_move.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/tests/test_orphans.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/tests/test_paths.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/tests/test_powerloss.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/tests/test_relocations.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/tests/test_seek.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/tests/test_shrink.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/tests/test_superblocks.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/littlefs/tests/test_truncate.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/mypy.ini +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/pyproject.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/requirements.txt +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/setup.cfg +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/setup.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/src/littlefs/context.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/src/littlefs/errors.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/src/littlefs/lfs.pxd +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/src/littlefs/py.typed +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/src/littlefs/repl.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/src/littlefs_python.egg-info/dependency_links.txt +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/src/littlefs_python.egg-info/entry_points.txt +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/src/littlefs_python.egg-info/not-zip-safe +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/src/littlefs_python.egg-info/requires.txt +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/src/littlefs_python.egg-info/top_level.txt +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/test/cli/test_create_and_repl.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/test/cli/test_walk_all.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/test/lfs/conftest.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/test/lfs/test_dir_functions.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/test/lfs/test_file_functions.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/test/lfs/test_fs_functions.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/test/test_attr.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/test/test_block_count.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/test/test_context.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/test/test_directories.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/test/test_files.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/test/test_grow.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/test/test_multiversion.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/test/test_name_max.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/test/test_remove_rename.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/test/test_version.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/test/test_walk.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.18.0}/test/test_windisk_context.py +0 -0
|
@@ -35,7 +35,7 @@ jobs:
|
|
|
35
35
|
platforms: all
|
|
36
36
|
|
|
37
37
|
- name: Build wheels
|
|
38
|
-
uses: pypa/cibuildwheel@v3.
|
|
38
|
+
uses: pypa/cibuildwheel@v3.4.1
|
|
39
39
|
|
|
40
40
|
- uses: actions/upload-artifact@v6
|
|
41
41
|
with:
|
|
@@ -57,7 +57,7 @@ jobs:
|
|
|
57
57
|
fetch-depth: 0
|
|
58
58
|
|
|
59
59
|
- name: Build wheels
|
|
60
|
-
uses: pypa/cibuildwheel@v3.
|
|
60
|
+
uses: pypa/cibuildwheel@v3.4.1
|
|
61
61
|
env:
|
|
62
62
|
CIBW_BUILD: ${{ matrix.cibw_build }}
|
|
63
63
|
CIBW_SKIP: "pp*"
|
|
@@ -119,7 +119,7 @@ jobs:
|
|
|
119
119
|
pattern: wheels-*
|
|
120
120
|
merge-multiple: true
|
|
121
121
|
|
|
122
|
-
- uses: pypa/gh-action-pypi-publish@v1.
|
|
122
|
+
- uses: pypa/gh-action-pypi-publish@v1.14.0
|
|
123
123
|
with:
|
|
124
124
|
user: __token__
|
|
125
125
|
password: ${{ secrets.pypi_api_token }}
|
|
@@ -58,7 +58,29 @@ if TYPE_CHECKING:
|
|
|
58
58
|
class LittleFS:
|
|
59
59
|
"""Littlefs file system"""
|
|
60
60
|
|
|
61
|
-
def __init__(
|
|
61
|
+
def __init__(
|
|
62
|
+
self,
|
|
63
|
+
context: Optional["UserContext"] = None,
|
|
64
|
+
mount=True,
|
|
65
|
+
filename_encoding: Optional[str] = None,
|
|
66
|
+
**kwargs,
|
|
67
|
+
) -> None:
|
|
68
|
+
"""
|
|
69
|
+
Parameters
|
|
70
|
+
----------
|
|
71
|
+
filename_encoding : Optional[str]
|
|
72
|
+
Encoding used to encode/decode filenames passed to and returned by
|
|
73
|
+
the filesystem. littlefs stores names as opaque byte strings, so this
|
|
74
|
+
is a free choice. Defaults to :data:`littlefs.lfs.FILENAME_ENCODING`
|
|
75
|
+
(``"utf-8"``). Set this when reading an image whose names were written
|
|
76
|
+
with a different encoding (e.g. ``"latin-1"`` or ``"shift-jis"``).
|
|
77
|
+
|
|
78
|
+
Note that littlefs's ``name_max`` limit is measured in *encoded
|
|
79
|
+
bytes*, not characters. With a multi-byte encoding such as UTF-8, a
|
|
80
|
+
single non-ASCII character consumes 2-4 bytes, so a name can exceed
|
|
81
|
+
``name_max`` (default 255) well before it looks long.
|
|
82
|
+
"""
|
|
83
|
+
self.filename_encoding = filename_encoding or lfs.FILENAME_ENCODING
|
|
62
84
|
self.cfg = lfs.LFSConfig(context=context, **kwargs)
|
|
63
85
|
self.fs = lfs.LFSFilesystem()
|
|
64
86
|
|
|
@@ -204,7 +226,7 @@ class LittleFS:
|
|
|
204
226
|
buffering = -1
|
|
205
227
|
|
|
206
228
|
try:
|
|
207
|
-
fh = lfs.file_open(self.fs, fname, mode)
|
|
229
|
+
fh = lfs.file_open(self.fs, fname, mode, self.filename_encoding)
|
|
208
230
|
except LittleFSError as e:
|
|
209
231
|
# Try to map to standard Python exceptions
|
|
210
232
|
if e.code == LittleFSError.Error.LFS_ERR_NOENT:
|
|
@@ -251,15 +273,15 @@ class LittleFS:
|
|
|
251
273
|
|
|
252
274
|
def getattr(self, path: str, typ: Union[str, bytes, int]) -> bytes:
|
|
253
275
|
typ = _typ_to_uint8(typ)
|
|
254
|
-
return lfs.getattr(self.fs, path, typ)
|
|
276
|
+
return lfs.getattr(self.fs, path, typ, self.filename_encoding)
|
|
255
277
|
|
|
256
278
|
def setattr(self, path: str, typ: Union[str, bytes, int], data: bytes) -> None:
|
|
257
279
|
typ = _typ_to_uint8(typ)
|
|
258
|
-
lfs.setattr(self.fs, path, typ, data)
|
|
280
|
+
lfs.setattr(self.fs, path, typ, data, self.filename_encoding)
|
|
259
281
|
|
|
260
282
|
def removeattr(self, path: str, typ: Union[str, bytes, int]) -> None:
|
|
261
283
|
typ = _typ_to_uint8(typ)
|
|
262
|
-
lfs.removeattr(self.fs, path, typ)
|
|
284
|
+
lfs.removeattr(self.fs, path, typ, self.filename_encoding)
|
|
263
285
|
|
|
264
286
|
def listdir(self, path=".") -> List[str]:
|
|
265
287
|
"""List directory content
|
|
@@ -274,7 +296,7 @@ class LittleFS:
|
|
|
274
296
|
def mkdir(self, path: str) -> int:
|
|
275
297
|
"""Create a new directory"""
|
|
276
298
|
try:
|
|
277
|
-
return lfs.mkdir(self.fs, path)
|
|
299
|
+
return lfs.mkdir(self.fs, path, self.filename_encoding)
|
|
278
300
|
except errors.LittleFSError as e:
|
|
279
301
|
if e.code == LittleFSError.Error.LFS_ERR_EXIST:
|
|
280
302
|
msg = "[LittleFSError {:d}] Cannot create a file when that file already exists: '{:s}'.".format(
|
|
@@ -310,7 +332,7 @@ class LittleFS:
|
|
|
310
332
|
If ``true`` and ``path`` is a directory, recursively remove all children files/folders.
|
|
311
333
|
"""
|
|
312
334
|
try:
|
|
313
|
-
lfs.remove(self.fs, path)
|
|
335
|
+
lfs.remove(self.fs, path, self.filename_encoding)
|
|
314
336
|
return
|
|
315
337
|
except errors.LittleFSError as e:
|
|
316
338
|
if e.code == LittleFSError.Error.LFS_ERR_NOENT:
|
|
@@ -326,7 +348,7 @@ class LittleFS:
|
|
|
326
348
|
# Recursively delete the ``path`` directory
|
|
327
349
|
for elem in self.scandir(path):
|
|
328
350
|
self.remove(path + "/" + elem.name, recursive=True)
|
|
329
|
-
lfs.remove(self.fs, path)
|
|
351
|
+
lfs.remove(self.fs, path, self.filename_encoding)
|
|
330
352
|
|
|
331
353
|
def removedirs(self, name):
|
|
332
354
|
"""Remove directories recursively
|
|
@@ -351,7 +373,7 @@ class LittleFS:
|
|
|
351
373
|
|
|
352
374
|
def rename(self, src: str, dst: str) -> int:
|
|
353
375
|
"""Rename a file or directory"""
|
|
354
|
-
return lfs.rename(self.fs, src, dst)
|
|
376
|
+
return lfs.rename(self.fs, src, dst, self.filename_encoding)
|
|
355
377
|
|
|
356
378
|
def rmdir(self, path: str) -> int:
|
|
357
379
|
"""Remove a directory
|
|
@@ -362,17 +384,19 @@ class LittleFS:
|
|
|
362
384
|
|
|
363
385
|
def scandir(self, path=".") -> Iterator["LFSStat"]:
|
|
364
386
|
"""List directory content"""
|
|
365
|
-
dh = lfs.dir_open(self.fs, path)
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
387
|
+
dh = lfs.dir_open(self.fs, path, self.filename_encoding)
|
|
388
|
+
try:
|
|
389
|
+
info = lfs.dir_read(self.fs, dh, self.filename_encoding)
|
|
390
|
+
while info:
|
|
391
|
+
if info.name not in [".", ".."]:
|
|
392
|
+
yield info
|
|
393
|
+
info = lfs.dir_read(self.fs, dh, self.filename_encoding)
|
|
394
|
+
finally:
|
|
395
|
+
lfs.dir_close(self.fs, dh)
|
|
372
396
|
|
|
373
397
|
def stat(self, path: str) -> "LFSStat":
|
|
374
398
|
"""Get the status of a file or directory"""
|
|
375
|
-
return lfs.stat(self.fs, path)
|
|
399
|
+
return lfs.stat(self.fs, path, self.filename_encoding)
|
|
376
400
|
|
|
377
401
|
def unlink(self, path: str) -> int:
|
|
378
402
|
"""Remove a file or directory
|
|
@@ -19,14 +19,20 @@ _suffix_map = {
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
def _fs_from_args(args: argparse.Namespace, block_count=None, mount=True, context: UserContext = None) -> LittleFS:
|
|
22
|
+
"""Build LittleFS from CLI args. Options name_max, attr_max, file_max are stored in the
|
|
23
|
+
superblock and must match when mounting an existing image. inline_max is format-relevant
|
|
24
|
+
(limiting it may improve flash usage)."""
|
|
22
25
|
block_count = block_count if block_count is not None else getattr(args, "block_count", 0)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
kwargs = {
|
|
27
|
+
"block_size": args.block_size,
|
|
28
|
+
"block_count": block_count,
|
|
29
|
+
"name_max": args.name_max,
|
|
30
|
+
"inline_max": args.inline_max,
|
|
31
|
+
"attr_max": args.attr_max,
|
|
32
|
+
"file_max": args.file_max,
|
|
33
|
+
"filename_encoding": getattr(args, "filename_encoding", None),
|
|
34
|
+
}
|
|
35
|
+
return LittleFS(context=context, mount=mount, **kwargs)
|
|
30
36
|
|
|
31
37
|
|
|
32
38
|
def size_parser(size_str):
|
|
@@ -81,6 +87,12 @@ def create(parser: argparse.ArgumentParser, args: argparse.Namespace) -> int:
|
|
|
81
87
|
print(f" Image Size: {args.fs_size:9d} / 0x{args.fs_size:X}")
|
|
82
88
|
print(f" Block Count: {args.block_count:9d}")
|
|
83
89
|
print(f" Name Max: {args.name_max:9d}")
|
|
90
|
+
if args.inline_max:
|
|
91
|
+
print(f" Inline Max: {args.inline_max:9d} / 0x{args.inline_max:X}")
|
|
92
|
+
if args.attr_max:
|
|
93
|
+
print(f" Attr Max: {args.attr_max:9d}")
|
|
94
|
+
if args.file_max:
|
|
95
|
+
print(f" File Max: {args.file_max:9d}")
|
|
84
96
|
print(f" Image: {args.destination}")
|
|
85
97
|
|
|
86
98
|
source = Path(args.source).absolute()
|
|
@@ -144,6 +156,12 @@ def _mount_from_context(parser: argparse.ArgumentParser, args: argparse.Namespac
|
|
|
144
156
|
print(f" Image Size: {input_image_size:9d} / 0x{input_image_size:X}")
|
|
145
157
|
print(f" Block Count: {fs.block_count:9d}")
|
|
146
158
|
print(f" Name Max: {args.name_max:9d}")
|
|
159
|
+
if args.inline_max:
|
|
160
|
+
print(f" Inline Max: {args.inline_max:9d} / 0x{args.inline_max:X}")
|
|
161
|
+
if args.attr_max:
|
|
162
|
+
print(f" Attr Max: {args.attr_max:9d}")
|
|
163
|
+
if args.file_max:
|
|
164
|
+
print(f" File Max: {args.file_max:9d}")
|
|
147
165
|
print(f" Image: {args.source}")
|
|
148
166
|
|
|
149
167
|
return fs
|
|
@@ -251,12 +269,41 @@ def get_parser():
|
|
|
251
269
|
|
|
252
270
|
common_parser = argparse.ArgumentParser(add_help=False)
|
|
253
271
|
common_parser.add_argument("-v", "--verbose", action="count", default=0)
|
|
272
|
+
# Stored in superblock; must match when mounting an existing image:
|
|
254
273
|
common_parser.add_argument(
|
|
255
274
|
"--name-max",
|
|
256
275
|
type=size_parser,
|
|
257
276
|
default=255,
|
|
258
277
|
help="LittleFS max file path length. Defaults to LittleFS's default (255).",
|
|
259
278
|
)
|
|
279
|
+
common_parser.add_argument(
|
|
280
|
+
"--attr-max",
|
|
281
|
+
type=int,
|
|
282
|
+
default=0,
|
|
283
|
+
help="Max custom attribute size per file. Defaults to LittleFS's default (0 = use library default).",
|
|
284
|
+
)
|
|
285
|
+
common_parser.add_argument(
|
|
286
|
+
"--file-max",
|
|
287
|
+
type=int,
|
|
288
|
+
default=0,
|
|
289
|
+
help="Max number of open files. Defaults to LittleFS's default (0 = use library default).",
|
|
290
|
+
)
|
|
291
|
+
# Format option: limiting inline_max may improve flash usage.
|
|
292
|
+
common_parser.add_argument(
|
|
293
|
+
"--inline-max",
|
|
294
|
+
type=size_parser,
|
|
295
|
+
default=0,
|
|
296
|
+
help="Max inline file size; 0 = use library default. Limiting can improve flash usage.",
|
|
297
|
+
)
|
|
298
|
+
# Host-side encode/decode choice; never stored in the image. The same encoding
|
|
299
|
+
# must be used to extract an image as was used to create it, otherwise filenames
|
|
300
|
+
# will fail to decode or come out as mojibake.
|
|
301
|
+
common_parser.add_argument(
|
|
302
|
+
"--filename-encoding",
|
|
303
|
+
default=None,
|
|
304
|
+
help="Encoding for filenames stored in the image. Defaults to utf-8. "
|
|
305
|
+
"Use e.g. latin-1 or shift-jis for images whose names use a different encoding.",
|
|
306
|
+
)
|
|
260
307
|
|
|
261
308
|
subparsers = parser.add_subparsers(required=True, title="Available Commands", dest="command")
|
|
262
309
|
|