littlefs-python 0.17.1__tar.gz → 0.19.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.19.0}/.github/workflows/deploy.yml +38 -12
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/.github/workflows/run-tests.yml +10 -2
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/PKG-INFO +1 -1
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/README.md +1 -1
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/lfs.c +25 -16
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/lfs.h +6 -5
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/tests/test_alloc.toml +183 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/src/littlefs/__init__.py +41 -17
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/src/littlefs/__main__.py +54 -7
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/src/littlefs/lfs.c +3984 -4095
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/src/littlefs/lfs.pyi +12 -10
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/src/littlefs/lfs.pyx +40 -25
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/src/littlefs_python.egg-info/PKG-INFO +1 -1
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/src/littlefs_python.egg-info/SOURCES.txt +3 -0
- littlefs_python-0.19.0/src/littlefs_python.egg-info/scm_file_list.json +131 -0
- littlefs_python-0.19.0/src/littlefs_python.egg-info/scm_version.json +8 -0
- littlefs_python-0.19.0/test/cli/test_create_and_extract.py +193 -0
- littlefs_python-0.19.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.19.0}/.gitattributes +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/.github/dependabot.yml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/.gitignore +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/.gitmodules +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/.pre-commit-config.yaml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/.readthedocs.yml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/LICENSE +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/MANIFEST.in +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/README.rst +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/ci/build-wheels.sh +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/ci/download_release_files.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/docs/Makefile +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/docs/api/index.rst +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/docs/cli.rst +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/docs/conf.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/docs/doc8.ini +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/docs/examples/index.rst +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/docs/index.rst +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/docs/make.bat +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/docs/requirements.txt +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/docs/usage.rst +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/examples/mkfsimg.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/examples/walk.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/.git +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/.gitattributes +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/.github/workflows/post-release.yml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/.github/workflows/release.yml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/.github/workflows/status.yml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/.github/workflows/test.yml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/.gitignore +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/DESIGN.md +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/LICENSE.md +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/Makefile +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/SPEC.md +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/bd/lfs_emubd.c +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/bd/lfs_emubd.h +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/bd/lfs_filebd.c +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/bd/lfs_filebd.h +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/bd/lfs_rambd.c +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/bd/lfs_rambd.h +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/benches/bench_dir.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/benches/bench_file.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/benches/bench_superblock.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/lfs_util.c +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/lfs_util.h +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/runners/bench_runner.c +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/runners/bench_runner.h +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/runners/test_runner.c +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/runners/test_runner.h +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/scripts/bench.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/scripts/changeprefix.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/scripts/code.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/scripts/cov.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/scripts/data.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/scripts/perf.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/scripts/perfbd.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/scripts/plot.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/scripts/plotmpl.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/scripts/prettyasserts.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/scripts/readblock.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/scripts/readmdir.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/scripts/readtree.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/scripts/stack.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/scripts/structs.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/scripts/summary.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/scripts/tailpipe.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/scripts/teepipe.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/scripts/test.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/scripts/tracebd.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/scripts/watch.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/tests/test_attrs.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/tests/test_badblocks.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/tests/test_bd.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/tests/test_compat.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/tests/test_dirs.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/tests/test_entries.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/tests/test_evil.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/tests/test_exhaustion.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/tests/test_files.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/tests/test_interspersed.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/tests/test_move.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/tests/test_orphans.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/tests/test_paths.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/tests/test_powerloss.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/tests/test_relocations.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/tests/test_seek.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/tests/test_shrink.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/tests/test_superblocks.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/littlefs/tests/test_truncate.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/mypy.ini +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/pyproject.toml +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/requirements.txt +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/setup.cfg +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/setup.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/src/littlefs/context.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/src/littlefs/errors.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/src/littlefs/lfs.pxd +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/src/littlefs/py.typed +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/src/littlefs/repl.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/src/littlefs_python.egg-info/dependency_links.txt +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/src/littlefs_python.egg-info/entry_points.txt +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/src/littlefs_python.egg-info/not-zip-safe +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/src/littlefs_python.egg-info/requires.txt +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/src/littlefs_python.egg-info/top_level.txt +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/test/cli/test_create_and_repl.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/test/cli/test_walk_all.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/test/lfs/conftest.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/test/lfs/test_dir_functions.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/test/lfs/test_file_functions.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/test/lfs/test_fs_functions.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/test/test_attr.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/test/test_block_count.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/test/test_context.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/test/test_directories.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/test/test_files.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/test/test_grow.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/test/test_multiversion.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/test/test_name_max.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/test/test_remove_rename.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/test/test_version.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/test/test_walk.py +0 -0
- {littlefs_python-0.17.1 → littlefs_python-0.19.0}/test/test_windisk_context.py +0 -0
|
@@ -23,21 +23,21 @@ jobs:
|
|
|
23
23
|
CIBW_ARCHS_LINUX: "x86_64 i686 aarch64"
|
|
24
24
|
|
|
25
25
|
steps:
|
|
26
|
-
- uses: actions/checkout@
|
|
26
|
+
- uses: actions/checkout@v7
|
|
27
27
|
with:
|
|
28
28
|
submodules: "recursive"
|
|
29
29
|
fetch-depth: 0
|
|
30
30
|
|
|
31
31
|
- name: Setup QEMU # Needed to build aarch64 wheels
|
|
32
32
|
if: runner.os == 'Linux'
|
|
33
|
-
uses: docker/setup-qemu-action@
|
|
33
|
+
uses: docker/setup-qemu-action@v4
|
|
34
34
|
with:
|
|
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
|
-
- uses: actions/upload-artifact@
|
|
40
|
+
- uses: actions/upload-artifact@v7
|
|
41
41
|
with:
|
|
42
42
|
name: wheels-${{ matrix.os }}
|
|
43
43
|
path: ./wheelhouse/*.whl
|
|
@@ -51,13 +51,13 @@ jobs:
|
|
|
51
51
|
cibw_archs: ["arm64"]
|
|
52
52
|
|
|
53
53
|
steps:
|
|
54
|
-
- uses: actions/checkout@
|
|
54
|
+
- uses: actions/checkout@v7
|
|
55
55
|
with:
|
|
56
56
|
submodules: "recursive"
|
|
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*"
|
|
@@ -84,16 +84,42 @@ jobs:
|
|
|
84
84
|
delocate-listdeps --all {dest_dir}/$WHEEL_SIMPLE_FILENAME
|
|
85
85
|
|
|
86
86
|
echo "DONE."
|
|
87
|
-
- uses: actions/upload-artifact@
|
|
87
|
+
- uses: actions/upload-artifact@v7
|
|
88
88
|
with:
|
|
89
89
|
name: wheels-macos-arm64
|
|
90
90
|
path: ./wheelhouse/*.whl
|
|
91
91
|
|
|
92
|
+
build_wheels_windows_arm64:
|
|
93
|
+
name: Build ARM64 wheels on ${{ matrix.os }}
|
|
94
|
+
runs-on: ${{ matrix.os }}
|
|
95
|
+
strategy:
|
|
96
|
+
matrix:
|
|
97
|
+
os: [windows-11-arm]
|
|
98
|
+
|
|
99
|
+
env:
|
|
100
|
+
# Native ARM64 CPython builds on Windows are available for 3.11+.
|
|
101
|
+
CIBW_BUILD: "cp311-* cp312-* cp313-* cp314-*"
|
|
102
|
+
CIBW_ARCHS_WINDOWS: "ARM64"
|
|
103
|
+
|
|
104
|
+
steps:
|
|
105
|
+
- uses: actions/checkout@v6
|
|
106
|
+
with:
|
|
107
|
+
submodules: "recursive"
|
|
108
|
+
fetch-depth: 0
|
|
109
|
+
|
|
110
|
+
- name: Build wheels
|
|
111
|
+
uses: pypa/cibuildwheel@v3.4.1
|
|
112
|
+
|
|
113
|
+
- uses: actions/upload-artifact@v6
|
|
114
|
+
with:
|
|
115
|
+
name: wheels-windows-arm64
|
|
116
|
+
path: ./wheelhouse/*.whl
|
|
117
|
+
|
|
92
118
|
build_sdist:
|
|
93
119
|
name: Build source distribution
|
|
94
120
|
runs-on: ubuntu-22.04
|
|
95
121
|
steps:
|
|
96
|
-
- uses: actions/checkout@
|
|
122
|
+
- uses: actions/checkout@v7
|
|
97
123
|
with:
|
|
98
124
|
submodules: "recursive"
|
|
99
125
|
fetch-depth: 0
|
|
@@ -103,23 +129,23 @@ jobs:
|
|
|
103
129
|
pip install build
|
|
104
130
|
python -m build . --sdist
|
|
105
131
|
|
|
106
|
-
- uses: actions/upload-artifact@
|
|
132
|
+
- uses: actions/upload-artifact@v7
|
|
107
133
|
with:
|
|
108
134
|
name: wheels-sdist
|
|
109
135
|
path: dist/*.tar.gz
|
|
110
136
|
|
|
111
137
|
upload_pypi:
|
|
112
|
-
needs: [build_wheels, build_wheels_macos_arm64, build_sdist]
|
|
138
|
+
needs: [build_wheels, build_wheels_macos_arm64, build_wheels_windows_arm64, build_sdist]
|
|
113
139
|
runs-on: ubuntu-22.04
|
|
114
140
|
if: ${{ inputs.upload_to_pypi }}
|
|
115
141
|
steps:
|
|
116
|
-
- uses: actions/download-artifact@
|
|
142
|
+
- uses: actions/download-artifact@v8
|
|
117
143
|
with:
|
|
118
144
|
path: dist
|
|
119
145
|
pattern: wheels-*
|
|
120
146
|
merge-multiple: true
|
|
121
147
|
|
|
122
|
-
- uses: pypa/gh-action-pypi-publish@v1.
|
|
148
|
+
- uses: pypa/gh-action-pypi-publish@v1.14.0
|
|
123
149
|
with:
|
|
124
150
|
user: __token__
|
|
125
151
|
password: ${{ secrets.pypi_api_token }}
|
|
@@ -14,11 +14,19 @@ jobs:
|
|
|
14
14
|
runs-on: ${{ matrix.os }}
|
|
15
15
|
strategy:
|
|
16
16
|
matrix:
|
|
17
|
-
os: [ubuntu-22.04, macos-15, windows-latest]
|
|
17
|
+
os: [ubuntu-22.04, macos-15, windows-latest, windows-11-arm]
|
|
18
18
|
python-version: [3.8, 3.9, "3.10", "3.11", "3.12", "3.13", "3.14"]
|
|
19
|
+
exclude:
|
|
20
|
+
# Native ARM64 CPython builds on Windows are available for 3.11+.
|
|
21
|
+
- os: windows-11-arm
|
|
22
|
+
python-version: 3.8
|
|
23
|
+
- os: windows-11-arm
|
|
24
|
+
python-version: 3.9
|
|
25
|
+
- os: windows-11-arm
|
|
26
|
+
python-version: "3.10"
|
|
19
27
|
|
|
20
28
|
steps:
|
|
21
|
-
- uses: actions/checkout@
|
|
29
|
+
- uses: actions/checkout@v7
|
|
22
30
|
with:
|
|
23
31
|
submodules: "recursive"
|
|
24
32
|
- name: Set up Python ${{ matrix.python-version }}
|
|
@@ -192,7 +192,7 @@ More details on how littlefs works can be found in [DESIGN.md](DESIGN.md) and
|
|
|
192
192
|
## Testing
|
|
193
193
|
|
|
194
194
|
The littlefs comes with a test suite designed to run on a PC using the
|
|
195
|
-
[emulated block device](bd/
|
|
195
|
+
[emulated block device](bd/lfs_emubd.h) found in the `bd` directory.
|
|
196
196
|
The tests assume a Linux environment and can be started with make:
|
|
197
197
|
|
|
198
198
|
``` bash
|
|
@@ -258,7 +258,7 @@ static int lfs_bd_prog(lfs_t *lfs,
|
|
|
258
258
|
continue;
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
-
// pcache must have been flushed, either by programming
|
|
261
|
+
// pcache must have been flushed, either by programming an
|
|
262
262
|
// entire block or manually flushing the pcache
|
|
263
263
|
LFS_ASSERT(pcache->block == LFS_BLOCK_NULL);
|
|
264
264
|
|
|
@@ -286,7 +286,7 @@ static int lfs_bd_erase(lfs_t *lfs, lfs_block_t block) {
|
|
|
286
286
|
|
|
287
287
|
// some operations on paths
|
|
288
288
|
static inline lfs_size_t lfs_path_namelen(const char *path) {
|
|
289
|
-
return strcspn(path, "/");
|
|
289
|
+
return (lfs_size_t)strcspn(path, "/");
|
|
290
290
|
}
|
|
291
291
|
|
|
292
292
|
static inline bool lfs_path_islast(const char *path) {
|
|
@@ -1291,6 +1291,7 @@ static lfs_stag_t lfs_dir_fetchmatch(lfs_t *lfs,
|
|
|
1291
1291
|
|
|
1292
1292
|
// found a match for our fetcher?
|
|
1293
1293
|
if ((fmask & tag) == (fmask & ftag)) {
|
|
1294
|
+
LFS_ASSERT(cb != NULL);
|
|
1294
1295
|
int res = cb(data, tag, &(struct lfs_diskoff){
|
|
1295
1296
|
dir->pair[0], off+sizeof(tag)});
|
|
1296
1297
|
if (res < 0) {
|
|
@@ -1501,7 +1502,7 @@ nextname:
|
|
|
1501
1502
|
if (lfs_tag_type3(tag) == LFS_TYPE_DIR) {
|
|
1502
1503
|
name += strspn(name, "/");
|
|
1503
1504
|
}
|
|
1504
|
-
lfs_size_t namelen = strcspn(name, "/");
|
|
1505
|
+
lfs_size_t namelen = (lfs_size_t)strcspn(name, "/");
|
|
1505
1506
|
|
|
1506
1507
|
// skip '.'
|
|
1507
1508
|
if (namelen == 1 && memcmp(name, ".", 1) == 0) {
|
|
@@ -1520,7 +1521,7 @@ nextname:
|
|
|
1520
1521
|
int depth = 1;
|
|
1521
1522
|
while (true) {
|
|
1522
1523
|
suffix += strspn(suffix, "/");
|
|
1523
|
-
sufflen = strcspn(suffix, "/");
|
|
1524
|
+
sufflen = (lfs_size_t)strcspn(suffix, "/");
|
|
1524
1525
|
if (sufflen == 0) {
|
|
1525
1526
|
break;
|
|
1526
1527
|
}
|
|
@@ -1761,7 +1762,7 @@ static int lfs_dir_commitcrc(lfs_t *lfs, struct lfs_commit *commit) {
|
|
|
1761
1762
|
|
|
1762
1763
|
commit->off = noff;
|
|
1763
1764
|
// perturb valid bit?
|
|
1764
|
-
commit->ptag = ntag ^ ((
|
|
1765
|
+
commit->ptag = ntag ^ ((lfs_tag_t)(0x80 & ~eperturb) << 24);
|
|
1765
1766
|
// reset crc for next commit
|
|
1766
1767
|
commit->crc = 0xffffffff;
|
|
1767
1768
|
|
|
@@ -3244,10 +3245,12 @@ static int lfs_file_open_(lfs_t *lfs, lfs_file_t *file,
|
|
|
3244
3245
|
#endif
|
|
3245
3246
|
|
|
3246
3247
|
static int lfs_file_close_(lfs_t *lfs, lfs_file_t *file) {
|
|
3247
|
-
#ifndef LFS_READONLY
|
|
3248
|
-
int err = lfs_file_sync_(lfs, file);
|
|
3249
|
-
#else
|
|
3250
3248
|
int err = 0;
|
|
3249
|
+
#ifndef LFS_READONLY
|
|
3250
|
+
// it's not safe to do anything if our file errored
|
|
3251
|
+
if (!(file->flags & LFS_F_ERRED)) {
|
|
3252
|
+
err = lfs_file_sync_(lfs, file);
|
|
3253
|
+
}
|
|
3251
3254
|
#endif
|
|
3252
3255
|
|
|
3253
3256
|
// remove from list of mdirs
|
|
@@ -3429,18 +3432,12 @@ relocate:
|
|
|
3429
3432
|
|
|
3430
3433
|
#ifndef LFS_READONLY
|
|
3431
3434
|
static int lfs_file_sync_(lfs_t *lfs, lfs_file_t *file) {
|
|
3432
|
-
if (file->flags & LFS_F_ERRED) {
|
|
3433
|
-
// it's not safe to do anything if our file errored
|
|
3434
|
-
return 0;
|
|
3435
|
-
}
|
|
3436
|
-
|
|
3437
3435
|
int err = lfs_file_flush(lfs, file);
|
|
3438
3436
|
if (err) {
|
|
3439
3437
|
file->flags |= LFS_F_ERRED;
|
|
3440
3438
|
return err;
|
|
3441
3439
|
}
|
|
3442
3440
|
|
|
3443
|
-
|
|
3444
3441
|
if ((file->flags & LFS_F_DIRTY) &&
|
|
3445
3442
|
!lfs_pair_isnull(file->m.pair)) {
|
|
3446
3443
|
// before we commit metadata, we need sync the disk to make sure
|
|
@@ -3485,6 +3482,17 @@ static int lfs_file_sync_(lfs_t *lfs, lfs_file_t *file) {
|
|
|
3485
3482
|
file->flags &= ~LFS_F_DIRTY;
|
|
3486
3483
|
}
|
|
3487
3484
|
|
|
3485
|
+
// mark any other file handles as dirty + desync
|
|
3486
|
+
for (lfs_file_t *f = (lfs_file_t*)lfs->mlist; f; f = f->next) {
|
|
3487
|
+
if (file != f
|
|
3488
|
+
&& f->type == LFS_TYPE_REG
|
|
3489
|
+
&& lfs_pair_cmp(f->m.pair, file->m.pair) == 0
|
|
3490
|
+
&& f->id == file->id) {
|
|
3491
|
+
f->flags |= LFS_F_DUSTY;
|
|
3492
|
+
}
|
|
3493
|
+
}
|
|
3494
|
+
|
|
3495
|
+
file->flags &= ~LFS_F_ERRED & ~LFS_F_DUSTY;
|
|
3488
3496
|
return 0;
|
|
3489
3497
|
}
|
|
3490
3498
|
#endif
|
|
@@ -3692,7 +3700,7 @@ static lfs_ssize_t lfs_file_write_(lfs_t *lfs, lfs_file_t *file,
|
|
|
3692
3700
|
return nsize;
|
|
3693
3701
|
}
|
|
3694
3702
|
|
|
3695
|
-
file->flags &= ~LFS_F_ERRED;
|
|
3703
|
+
file->flags &= ~LFS_F_ERRED & ~LFS_F_DUSTY;
|
|
3696
3704
|
return nsize;
|
|
3697
3705
|
}
|
|
3698
3706
|
#endif
|
|
@@ -4771,7 +4779,8 @@ int lfs_fs_traverse_(lfs_t *lfs,
|
|
|
4771
4779
|
continue;
|
|
4772
4780
|
}
|
|
4773
4781
|
|
|
4774
|
-
if ((f->flags & LFS_F_DIRTY)
|
|
4782
|
+
if (((f->flags & LFS_F_DIRTY) || (f->flags & LFS_F_DUSTY))
|
|
4783
|
+
&& !(f->flags & LFS_F_INLINE)) {
|
|
4775
4784
|
int err = lfs_ctz_traverse(lfs, &f->cache, &lfs->rcache,
|
|
4776
4785
|
f->ctz.head, f->ctz.size, cb, data);
|
|
4777
4786
|
if (err) {
|
|
@@ -135,14 +135,15 @@ enum lfs_open_flags {
|
|
|
135
135
|
|
|
136
136
|
// internally used flags
|
|
137
137
|
#ifndef LFS_READONLY
|
|
138
|
-
LFS_F_DIRTY =
|
|
139
|
-
|
|
138
|
+
LFS_F_DIRTY = 0x00010000, // File does not match storage due to write
|
|
139
|
+
LFS_F_DUSTY = 0x00020000, // File does not match storage due to desync
|
|
140
|
+
LFS_F_WRITING = 0x00040000, // File has been written since last flush
|
|
140
141
|
#endif
|
|
141
|
-
LFS_F_READING =
|
|
142
|
+
LFS_F_READING = 0x00080000, // File has been read since last flush
|
|
142
143
|
#ifndef LFS_READONLY
|
|
143
|
-
LFS_F_ERRED =
|
|
144
|
+
LFS_F_ERRED = 0x00100000, // An error occurred during write
|
|
144
145
|
#endif
|
|
145
|
-
LFS_F_INLINE =
|
|
146
|
+
LFS_F_INLINE = 0x01000000, // Currently inlined in directory entry
|
|
146
147
|
};
|
|
147
148
|
|
|
148
149
|
// File seek flags
|
|
@@ -250,6 +250,189 @@ code = '''
|
|
|
250
250
|
}
|
|
251
251
|
'''
|
|
252
252
|
|
|
253
|
+
# multiple handle allocation test
|
|
254
|
+
#
|
|
255
|
+
# this tests that multiple open handles to the same file don't clobber
|
|
256
|
+
# each other
|
|
257
|
+
[cases.test_alloc_multihandle]
|
|
258
|
+
defines.FILES = 2
|
|
259
|
+
defines.SIZE = '(((BLOCK_SIZE-8)*(BLOCK_COUNT-6)) / FILES)'
|
|
260
|
+
defines.GC = [false, true]
|
|
261
|
+
defines.COMPACT_THRESH = ['-1', '0', 'BLOCK_SIZE/2']
|
|
262
|
+
defines.INFER_BC = [false, true]
|
|
263
|
+
defines.SYNC = [false, true]
|
|
264
|
+
code = '''
|
|
265
|
+
const char *names[] = {"eggs", "spinach"};
|
|
266
|
+
lfs_file_t files[FILES];
|
|
267
|
+
|
|
268
|
+
lfs_t lfs;
|
|
269
|
+
lfs_format(&lfs, cfg) => 0;
|
|
270
|
+
struct lfs_config cfg_ = *cfg;
|
|
271
|
+
if (INFER_BC) {
|
|
272
|
+
cfg_.block_count = 0;
|
|
273
|
+
}
|
|
274
|
+
lfs_mount(&lfs, &cfg_) => 0;
|
|
275
|
+
lfs_mkdir(&lfs, "breakfast") => 0;
|
|
276
|
+
|
|
277
|
+
// write one file
|
|
278
|
+
char path[1024];
|
|
279
|
+
sprintf(path, "breakfast/quiche");
|
|
280
|
+
lfs_file_open(&lfs, &files[0], path,
|
|
281
|
+
LFS_O_RDWR | LFS_O_CREAT | LFS_O_EXCL) => 0;
|
|
282
|
+
if (GC) {
|
|
283
|
+
lfs_fs_gc(&lfs) => 0;
|
|
284
|
+
}
|
|
285
|
+
size_t size = strlen(names[0]);
|
|
286
|
+
for (lfs_size_t i = 0; i < SIZE; i += size) {
|
|
287
|
+
lfs_file_write(&lfs, &files[0], names[0], size) => size;
|
|
288
|
+
}
|
|
289
|
+
// sync?
|
|
290
|
+
if (SYNC) {
|
|
291
|
+
lfs_file_sync(&lfs, &files[0]) => 0;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// write the other file
|
|
295
|
+
sprintf(path, "breakfast/quiche");
|
|
296
|
+
lfs_file_open(&lfs, &files[1], path,
|
|
297
|
+
LFS_O_RDWR | LFS_O_CREAT | LFS_O_TRUNC) => 0;
|
|
298
|
+
if (GC) {
|
|
299
|
+
lfs_fs_gc(&lfs) => 0;
|
|
300
|
+
}
|
|
301
|
+
size = strlen(names[1]);
|
|
302
|
+
for (lfs_size_t i = 0; i < SIZE; i += size) {
|
|
303
|
+
lfs_file_write(&lfs, &files[1], names[1], size) => size;
|
|
304
|
+
}
|
|
305
|
+
// sync?
|
|
306
|
+
if (SYNC) {
|
|
307
|
+
lfs_file_sync(&lfs, &files[1]) => 0;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// try to read from both
|
|
311
|
+
for (int n = 0; n < FILES; n++) {
|
|
312
|
+
lfs_file_rewind(&lfs, &files[n]) => 0;
|
|
313
|
+
size_t size = strlen(names[n]);
|
|
314
|
+
for (lfs_size_t i = 0; i < SIZE; i += size) {
|
|
315
|
+
uint8_t buffer[1024];
|
|
316
|
+
lfs_file_read(&lfs, &files[n], buffer, size) => size;
|
|
317
|
+
assert(memcmp(buffer, names[n], size) == 0);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
for (int n = 0; n < FILES; n++) {
|
|
321
|
+
lfs_file_close(&lfs, &files[n]) => 0;
|
|
322
|
+
}
|
|
323
|
+
lfs_unmount(&lfs) => 0;
|
|
324
|
+
|
|
325
|
+
// check after remounting
|
|
326
|
+
lfs_mount(&lfs, &cfg_) => 0;
|
|
327
|
+
{
|
|
328
|
+
// last one wins
|
|
329
|
+
int n = FILES-1;
|
|
330
|
+
char path[1024];
|
|
331
|
+
sprintf(path, "breakfast/quiche");
|
|
332
|
+
lfs_file_t file;
|
|
333
|
+
lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
|
|
334
|
+
size_t size = strlen(names[n]);
|
|
335
|
+
for (lfs_size_t i = 0; i < SIZE; i += size) {
|
|
336
|
+
uint8_t buffer[1024];
|
|
337
|
+
lfs_file_read(&lfs, &file, buffer, size) => size;
|
|
338
|
+
assert(memcmp(buffer, names[n], size) == 0);
|
|
339
|
+
}
|
|
340
|
+
lfs_file_close(&lfs, &file) => 0;
|
|
341
|
+
}
|
|
342
|
+
lfs_unmount(&lfs) => 0;
|
|
343
|
+
'''
|
|
344
|
+
|
|
345
|
+
# multiple handle allocation reuse test
|
|
346
|
+
[cases.test_alloc_multihandle_reuse]
|
|
347
|
+
defines.FILES = 2
|
|
348
|
+
defines.SIZE = '(((BLOCK_SIZE-8)*(BLOCK_COUNT-6)) / (FILES+1))'
|
|
349
|
+
defines.CYCLES = [1, 10]
|
|
350
|
+
defines.INFER_BC = [false, true]
|
|
351
|
+
defines.SYNC = [false, true]
|
|
352
|
+
code = '''
|
|
353
|
+
const char *names[] = {"eggs", "spinach"};
|
|
354
|
+
lfs_file_t files[FILES];
|
|
355
|
+
|
|
356
|
+
lfs_t lfs;
|
|
357
|
+
lfs_format(&lfs, cfg) => 0;
|
|
358
|
+
struct lfs_config cfg_ = *cfg;
|
|
359
|
+
if (INFER_BC) {
|
|
360
|
+
cfg_.block_count = 0;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
lfs_mount(&lfs, &cfg_) => 0;
|
|
364
|
+
lfs_mkdir(&lfs, "breakfast") => 0;
|
|
365
|
+
|
|
366
|
+
// write one file
|
|
367
|
+
char path[1024];
|
|
368
|
+
sprintf(path, "breakfast/quiche");
|
|
369
|
+
lfs_file_open(&lfs, &files[0], path,
|
|
370
|
+
LFS_O_RDWR | LFS_O_CREAT | LFS_O_EXCL) => 0;
|
|
371
|
+
if (GC) {
|
|
372
|
+
lfs_fs_gc(&lfs) => 0;
|
|
373
|
+
}
|
|
374
|
+
size_t size = strlen(names[0]);
|
|
375
|
+
for (lfs_size_t i = 0; i < SIZE; i += size) {
|
|
376
|
+
lfs_file_write(&lfs, &files[0], names[0], size) => size;
|
|
377
|
+
}
|
|
378
|
+
// sync?
|
|
379
|
+
if (SYNC) {
|
|
380
|
+
lfs_file_sync(&lfs, &files[0]) => 0;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
for (int c = 0; c < CYCLES; c++) {
|
|
384
|
+
// write the other file
|
|
385
|
+
sprintf(path, "breakfast/quiche");
|
|
386
|
+
lfs_file_open(&lfs, &files[1], path,
|
|
387
|
+
LFS_O_RDWR | LFS_O_CREAT | LFS_O_TRUNC) => 0;
|
|
388
|
+
if (GC) {
|
|
389
|
+
lfs_fs_gc(&lfs) => 0;
|
|
390
|
+
}
|
|
391
|
+
size = strlen(names[1]);
|
|
392
|
+
for (lfs_size_t i = 0; i < SIZE; i += size) {
|
|
393
|
+
lfs_file_write(&lfs, &files[1], names[1], size) => size;
|
|
394
|
+
}
|
|
395
|
+
// sync?
|
|
396
|
+
if (SYNC) {
|
|
397
|
+
lfs_file_sync(&lfs, &files[1]) => 0;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// try to read from both
|
|
401
|
+
for (int n = 0; n < FILES; n++) {
|
|
402
|
+
lfs_file_rewind(&lfs, &files[n]) => 0;
|
|
403
|
+
size_t size = strlen(names[n]);
|
|
404
|
+
for (lfs_size_t i = 0; i < SIZE; i += size) {
|
|
405
|
+
uint8_t buffer[1024];
|
|
406
|
+
lfs_file_read(&lfs, &files[n], buffer, size) => size;
|
|
407
|
+
assert(memcmp(buffer, names[n], size) == 0);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
lfs_file_close(&lfs, &files[1]) => 0;
|
|
412
|
+
}
|
|
413
|
+
lfs_file_close(&lfs, &files[0]) => 0;
|
|
414
|
+
lfs_unmount(&lfs) => 0;
|
|
415
|
+
|
|
416
|
+
// check after remounting
|
|
417
|
+
lfs_mount(&lfs, &cfg_) => 0;
|
|
418
|
+
{
|
|
419
|
+
// last one wins
|
|
420
|
+
int n = (SYNC) ? FILES-1 : 0;
|
|
421
|
+
char path[1024];
|
|
422
|
+
sprintf(path, "breakfast/quiche");
|
|
423
|
+
lfs_file_t file;
|
|
424
|
+
lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
|
|
425
|
+
size_t size = strlen(names[n]);
|
|
426
|
+
for (int i = 0; i < SIZE; i += size) {
|
|
427
|
+
uint8_t buffer[1024];
|
|
428
|
+
lfs_file_read(&lfs, &file, buffer, size) => size;
|
|
429
|
+
assert(memcmp(buffer, names[n], size) == 0);
|
|
430
|
+
}
|
|
431
|
+
lfs_file_close(&lfs, &file) => 0;
|
|
432
|
+
}
|
|
433
|
+
lfs_unmount(&lfs) => 0;
|
|
434
|
+
'''
|
|
435
|
+
|
|
253
436
|
# exhaustion test
|
|
254
437
|
[cases.test_alloc_exhaustion]
|
|
255
438
|
defines.INFER_BC = [false, true]
|
|
@@ -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
|