mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-24 03:06:33 +00:00
Berry add path.rename()
(#20840)
This commit is contained in:
parent
e55471e084
commit
92b9190817
@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file.
|
||||
|
||||
## [13.4.0.2]
|
||||
### Added
|
||||
- Berry add `path.rename()`
|
||||
|
||||
### Breaking Changed
|
||||
|
||||
|
@ -8,3 +8,4 @@
|
||||
#define MPATH_EXISTS 4
|
||||
#define MPATH_MODIFIED 5
|
||||
#define MPATH_REMOVE 6
|
||||
#define MPATH_RENAME 7
|
||||
|
@ -36,6 +36,9 @@ static int m_path_mkdir(bvm *vm) {
|
||||
static int m_path_rmdir(bvm *vm) {
|
||||
return _m_path_action(vm, MPATH_RMDIR);
|
||||
}
|
||||
static int m_path_rename(bvm *vm) {
|
||||
return _m_path_action(vm, MPATH_RENAME);
|
||||
}
|
||||
static int m_path_exists(bvm *vm) {
|
||||
return _m_path_action(vm, MPATH_EXISTS);
|
||||
}
|
||||
@ -69,6 +72,7 @@ module path (scope: global, file: tasmota_path) {
|
||||
format, func(m_path_format)
|
||||
mkdir, func(m_path_mkdir)
|
||||
rmdir, func(m_path_rmdir)
|
||||
rename, func(m_path_rename)
|
||||
}
|
||||
@const_object_info_end */
|
||||
#include "be_fixed_tasmota_path.h"
|
||||
|
@ -119,7 +119,8 @@ extern "C" {
|
||||
break;
|
||||
}
|
||||
|
||||
if (be_top(vm) >= 1 && be_isstring(vm, 1)) {
|
||||
int argc = be_top(vm);
|
||||
if (argc >= 1 && be_isstring(vm, 1)) {
|
||||
const char *path = be_tostring(vm, 1);
|
||||
if (path != nullptr) {
|
||||
switch (action){
|
||||
@ -135,6 +136,16 @@ extern "C" {
|
||||
case MPATH_MKDIR:
|
||||
res = zip_ufsp.mkdir(path);
|
||||
break;
|
||||
case MPATH_RENAME:
|
||||
{
|
||||
if (argc >= 2 && be_isstring(vm, 2)) {
|
||||
const char *path2 = be_tostring(vm, 2);
|
||||
res = zip_ufsp.rename(path, path2);
|
||||
} else {
|
||||
res = -1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MPATH_LISTDIR:
|
||||
be_newobject(vm, "list"); // add our list object and fall through
|
||||
returnit = 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user