|
@@ -11,7 +11,7 @@
|
|
|
#include "flash_fs.h"
|
|
|
#include "c_string.h"
|
|
|
|
|
|
-static int file_fd = FS_OPEN_OK - 1;
|
|
|
+static volatile int file_fd = FS_OPEN_OK - 1;
|
|
|
|
|
|
// Lua: open(filename, mode)
|
|
|
static int file_open( lua_State* L )
|
|
@@ -48,21 +48,6 @@ static int file_close( lua_State* L )
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-#if defined(BUILD_WOFS)
|
|
|
-// Lua: list()
|
|
|
-static int file_list( lua_State* L )
|
|
|
-{
|
|
|
- uint32_t start = 0;
|
|
|
- size_t act_len = 0;
|
|
|
- char fsname[ FS_NAME_MAX_LENGTH + 1 ];
|
|
|
- lua_newtable( L );
|
|
|
- while( FS_FILE_OK == wofs_next(&start, fsname, FS_NAME_MAX_LENGTH, &act_len) ){
|
|
|
- lua_pushinteger(L, act_len);
|
|
|
- lua_setfield( L, -2, fsname );
|
|
|
- }
|
|
|
- return 1;
|
|
|
-}
|
|
|
-
|
|
|
// Lua: format()
|
|
|
static int file_format( lua_State* L )
|
|
|
{
|
|
@@ -71,7 +56,7 @@ static int file_format( lua_State* L )
|
|
|
if( !fs_format() )
|
|
|
{
|
|
|
NODE_ERR( "\ni*** ERROR ***: unable to format. FS might be compromised.\n" );
|
|
|
- NODE_ERR( "It is advised to re-flash the nodeMcu image.\n" );
|
|
|
+ NODE_ERR( "It is advised to re-flash the NodeMCU image.\n" );
|
|
|
}
|
|
|
else{
|
|
|
NODE_ERR( "format done.\n" );
|
|
@@ -79,6 +64,21 @@ static int file_format( lua_State* L )
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+#if defined(BUILD_WOFS)
|
|
|
+// Lua: list()
|
|
|
+static int file_list( lua_State* L )
|
|
|
+{
|
|
|
+ uint32_t start = 0;
|
|
|
+ size_t act_len = 0;
|
|
|
+ char fsname[ FS_NAME_MAX_LENGTH + 1 ];
|
|
|
+ lua_newtable( L );
|
|
|
+ while( FS_FILE_OK == wofs_next(&start, fsname, FS_NAME_MAX_LENGTH, &act_len) ){
|
|
|
+ lua_pushinteger(L, act_len);
|
|
|
+ lua_setfield( L, -2, fsname );
|
|
|
+ }
|
|
|
+ return 1;
|
|
|
+}
|
|
|
+
|
|
|
#elif defined(BUILD_SPIFFS)
|
|
|
|
|
|
extern spiffs fs;
|
|
@@ -275,8 +275,8 @@ const LUA_REG_TYPE file_map[] =
|
|
|
{ LSTRKEY( "writeline" ), LFUNCVAL( file_writeline ) },
|
|
|
{ LSTRKEY( "read" ), LFUNCVAL( file_read ) },
|
|
|
{ LSTRKEY( "readline" ), LFUNCVAL( file_readline ) },
|
|
|
-#if defined(BUILD_WOFS)
|
|
|
{ LSTRKEY( "format" ), LFUNCVAL( file_format ) },
|
|
|
+#if defined(BUILD_WOFS)
|
|
|
#elif defined(BUILD_SPIFFS)
|
|
|
{ LSTRKEY( "remove" ), LFUNCVAL( file_remove ) },
|
|
|
{ LSTRKEY( "seek" ), LFUNCVAL( file_seek ) },
|