Commit Graph

16 Commits

Author SHA1 Message Date
Johny Mattsson 55dbcc79d5 Added mkdir/rmdir support to file module. 2023-01-17 14:34:26 +11:00
Tom Sutcliffe e3883cd27b Fix file.list() zero sizes. Fixes #3549.
The modern spiffs backend doesn't like stat("./somefile") for something
on the root of the filesystem, and instead only accepts "somefile"
(it also doesn't like "/somefile"). The error from stat was being
ignored which is why the file sizes all appeared to be zero.

The fix is to change file.list() to pass just the filename, unless a
directory was passed to list(). Also improved error handling a bit.
2022-11-08 16:10:47 +11:00
Johny Mattsson 4b4ce47ed1 Fix file listing on submounts. 2021-11-13 12:26:49 +11:00
Johny Mattsson a2ba49e36b Switch to IDF-provided VFS and standard `io` module.
The IDF-provided VFS resolves several issues:

 - The IDF components having a different view of the (virtual) file system
   compared to the Lua environment.

 - RTOS task/thread safety. Our legacy VFS was only ever safe to use
   from the LVM thread, which limited its usability. Upgrading it
   would have effectively required a reimplementation of the IDF VFS,
   which would have been a bigger task with larger on-going maintenance
   issues.

 - We're no longer needing to maintain our own SPIFFS component.

 - We're no longer needing to maintain our own FATFS component.

 - The legacy of the 8266's lack of standard C interface to the file system
   is no longer holding us back, meaning that we can use the standard
   Lua `io` module rather than the cobbled-together swiss army knife
   also known as the file module.

Of course, the downside is that we'll either have to declare a backwards
breakage in regard to the file module, or provide a Lua shim for the old
functions, where applicable.

Also included is some necessary integer type fixups in unrelated code,
which apparently had depended on some non-standard types in either the
SPIFFS or FATFS headers.

A memory leak issue in the sdmmc module was also found and fixed while
said module got switched over to the Espressif VFS.

Module documentation has been updated to match the new reality (and I
discovered in some places it wasn't even matching the old reality).
2021-10-20 21:49:11 +11:00
Johny Mattsson ea968de6f8 Fixup LROT_MASKs for all modules.
Search-and-replace considered harmful. I completely missed the need to
explicitly declare "fast" tag functions (__xyz) in the mask field to
LROT_BEGIN()/LROT_END() when I brought over the 5.1+5.3 support.
Without those flags set properly, the LVM doesn't even bother going
looking for those methods, which in this case led to garbage collection
not calling the __gc functions, among other horrible things.

Mea culpa.
2021-09-16 17:53:35 +10:00
Johny Mattsson dc27e9f7cf Updated modules to comply with __ ordering in rom tables. 2021-08-24 09:56:20 +10:00
Johny Mattsson 93140a89a5 Swap to luaL_pcallx for C module callbacks.
Bring on that stacktracey goodness!
2021-08-24 00:11:31 +10:00
Johny Mattsson 17df207a5f Port Terry's Lua 5.1 + 5.3 work from the esp8266 branch.
Changes have been kept to a minimum, but a serious chunk of work was
needed to move from 8266isms to IDFisms.

Some things got refactored into components/lua/common, in particular
the LFS location awareness.

As part of this work I also evicted our partition table manipulation
code, as with the current IDF it kept breaking checksums and rendering
things unbootable, which is the opposite of helpful (which was the
original intent behind it).

The uart module got relocated from base_nodemcu to the modules component
properly, after I worked out how to force its inclusion using Kconfig alone.
2021-08-22 02:03:05 +10:00
Johny Mattsson 16ef39e255 idf4: overhaul to new build system, part 1 of 3
Yet to come:
  - part 2: dealing with deprecated and removed APIs
  - part 3: making it actually work again
2021-07-15 16:27:03 +10:00
Johny Mattsson eaac369dec
LFS support for ESP32 NodeMCU (#2801)
* Port LFS from ESP8266 to ESP32
2019-07-22 19:13:43 +10:00
devsaurus 1f1eeaf358 fix unref default file descriptor while still in use 2019-07-03 23:54:08 +02:00
Javier Peletier d1eab2396c ESP32: remove use of luaM_free in file module (#2631)
* file: remove use of luaM_free

* added safe pushlstring function
2019-02-20 23:26:39 +01:00
devsaurus fdb96f51be update file and vfs to master 2018-11-04 00:42:08 +01:00
tomsci 48b9518d76 Add object-based file API to dev-esp32 branch (#2524)
* #2521: Add object-based file API to dev-esp32 branch

Merged in from master@c708828bbe853764b9de58fb8113a70f5a24002d minus
some VFS changes and similar.

* Updated file docs from master

Omitting:
* file.mount()
* reference to rtctime.epoch2cal()
* file.stat()

As these are not available in dev-esp32 branch

Unsure about whether "directories are not supported" is still true
2018-10-29 07:09:41 +01:00
devsaurus fb62011ddf Add sdmmc module and enable fatfs. 2017-04-30 22:49:54 +02:00
Johny Mattsson 60339b812b SPIFFS partition support, file module from dev.
Now uses the designated partition (type 0xC2, 0x00) unconditionally.
2016-09-22 17:18:22 +10:00