mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-19 16:56:34 +00:00
Berry: add path.rmdir(path), path.mkdir(path) (#18853)
(cherry picked from commit 7ce04b8624c88279c57d4a7556aabbe5f3317773)
This commit is contained in:
parent
a014f5495b
commit
c88bff5a46
@ -18,7 +18,10 @@
|
|||||||
#include "be_sys.h"
|
#include "be_sys.h"
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
// from be_port.c
|
||||||
extern int m_path_listdir(bvm *vm);
|
extern int m_path_listdir(bvm *vm);
|
||||||
|
extern int m_path_mkdir(bvm *vm);
|
||||||
|
extern int m_path_rmdir(bvm *vm);
|
||||||
|
|
||||||
static int m_path_exists(bvm *vm)
|
static int m_path_exists(bvm *vm)
|
||||||
{
|
{
|
||||||
@ -79,6 +82,8 @@ module path (scope: global, file: tasmota_path) {
|
|||||||
listdir, func(m_path_listdir)
|
listdir, func(m_path_listdir)
|
||||||
remove, func(m_path_remove)
|
remove, func(m_path_remove)
|
||||||
format, func(m_path_format)
|
format, func(m_path_format)
|
||||||
|
mkdir, func(m_path_mkdir)
|
||||||
|
rmdir, func(m_path_rmdir)
|
||||||
}
|
}
|
||||||
@const_object_info_end */
|
@const_object_info_end */
|
||||||
#include "be_fixed_tasmota_path.h"
|
#include "be_fixed_tasmota_path.h"
|
||||||
|
@ -131,6 +131,36 @@ extern "C" {
|
|||||||
#endif // USE_UFILESYS
|
#endif // USE_UFILESYS
|
||||||
be_return_nil(vm);
|
be_return_nil(vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int _m_path_mkdir_rmdir(bvm *vm, int remove) {
|
||||||
|
#ifdef USE_UFILESYS
|
||||||
|
const char *path = NULL;
|
||||||
|
if (be_top(vm) >= 1 && be_isstring(vm, 1)) {
|
||||||
|
path = be_tostring(vm, 1);
|
||||||
|
int res = 0;
|
||||||
|
if (path != nullptr) {
|
||||||
|
if (remove)
|
||||||
|
res = zip_ufsp.rmdir(path);
|
||||||
|
else
|
||||||
|
res = zip_ufsp.mkdir(path);
|
||||||
|
}
|
||||||
|
be_pushbool(vm, res);
|
||||||
|
} else {
|
||||||
|
be_pushbool(vm, bfalse);
|
||||||
|
}
|
||||||
|
be_return(vm);
|
||||||
|
#else // USE_UFILESYS
|
||||||
|
be_return_nil(vm);
|
||||||
|
#endif // USE_UFILESYS
|
||||||
|
}
|
||||||
|
|
||||||
|
int m_path_mkdir(bvm *vm) {
|
||||||
|
return _m_path_mkdir_rmdir(vm, 0);
|
||||||
|
}
|
||||||
|
int m_path_rmdir(bvm *vm) {
|
||||||
|
return _m_path_mkdir_rmdir(vm, 1);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BERRY_API char* be_readstring(char *buffer, size_t size)
|
BERRY_API char* be_readstring(char *buffer, size_t size)
|
||||||
@ -161,6 +191,7 @@ void* be_fopen(const char *filename, const char *modes)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
// return fopen(filename, modes);
|
// return fopen(filename, modes);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // USE_UFILESYS
|
#endif // USE_UFILESYS
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user