Skip to content

Commit 3379c55

Browse files
committed
fix: fix some api about create directory
1 parent 0006631 commit 3379c55

File tree

10 files changed

+38
-16
lines changed

10 files changed

+38
-16
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.4.11] - 2024-03-14
9+
10+
### Fixed
11+
12+
- Fix some api about create directory
13+
814
## [0.4.10] - 2024-03-14
915

1016
### Changed

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"type": "native",
55
"description": "A plugin engine for running LLSE plugins on LeviLamina",
66
"author": "LiteLDev",
7-
"version": "0.4.10",
7+
"version": "0.4.11",
88
"dependencies": [
99
{
1010
"name": "LegacyMoney"

src/legacy/api/DataAPI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ ConfIniClass* ConfIniClass::constructor(const Arguments& args) {
291291
if (args.size() >= 2) return new ConfIniClass(args.thiz(), path, args[1].toStr());
292292
else return new ConfIniClass(args.thiz(), path, "");
293293
}
294-
CATCH_C("Fail in Open JsonConfigFile!");
294+
CATCH_C("Fail in Open IniConfigFile!");
295295
}
296296

297297
bool ConfIniClass::flush() { return iniConf->SaveFile(iniConf->filePath.c_str(), true); }

src/legacy/api/FileSystemAPI.cpp

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <fstream>
1212
#include <ll/api/io/FileUtils.h>
1313
#include <string>
14+
#include <system_error>
1415

1516
using namespace std::filesystem;
1617

@@ -113,7 +114,7 @@ FileClass* FileClass::constructor(const Arguments& args) {
113114
string path = args[0].toStr();
114115
std::optional<std::string> dirPath = getDirectoryPath(path);
115116
if (dirPath.has_value()) {
116-
std::filesystem::create_directory(dirPath.value());
117+
std::filesystem::create_directories(dirPath.value());
117118
} else {
118119
LOG_ERROR_WITH_SCRIPT_INFO("Fail to create directory " + dirPath.value() + "!\n");
119120
return nullptr;
@@ -520,7 +521,7 @@ Local<Value> DirCreate(const Arguments& args) {
520521
CHECK_ARG_TYPE(args[0], ValueKind::kString);
521522

522523
try {
523-
return Boolean::newBoolean(std::filesystem::create_directory(args[0].toStr()));
524+
return Boolean::newBoolean(std::filesystem::create_directories(args[0].toStr()));
524525
} catch (const filesystem_error& e) {
525526
LOG_ERROR_WITH_SCRIPT_INFO("Fail to Create Dir " + args[0].asString().toString() + "!\n");
526527
return Boolean::newBoolean(false);
@@ -678,7 +679,12 @@ Local<Value> FileWriteTo(const Arguments& args) {
678679
string path = args[0].toStr();
679680
std::optional<std::string> dirPath = getDirectoryPath(path);
680681
if (dirPath.has_value()) {
681-
std::filesystem::create_directory(dirPath.value());
682+
std::error_code code;
683+
std::filesystem::create_directories(dirPath.value(), code);
684+
if (code) {
685+
LOG_ERROR_WITH_SCRIPT_INFO("Fail to create directory " + dirPath.value() + "!\n");
686+
return Boolean::newBoolean(false);
687+
}
682688
} else {
683689
LOG_ERROR_WITH_SCRIPT_INFO("Fail to create directory " + dirPath.value() + "!\n");
684690
return Boolean::newBoolean(false);
@@ -697,7 +703,12 @@ Local<Value> FileWriteLine(const Arguments& args) {
697703
string path = args[0].toStr();
698704
std::optional<std::string> dirPath = getDirectoryPath(path);
699705
if (dirPath.has_value()) {
700-
std::filesystem::create_directory(dirPath.value());
706+
std::error_code code;
707+
std::filesystem::create_directories(dirPath.value(), code);
708+
if (code) {
709+
LOG_ERROR_WITH_SCRIPT_INFO("Fail to create directory " + dirPath.value() + "!\n");
710+
return Boolean::newBoolean(false);
711+
}
701712
} else {
702713
LOG_ERROR_WITH_SCRIPT_INFO("Fail to create directory " + dirPath.value() + "!\n");
703714
return Boolean::newBoolean(false);
@@ -723,7 +734,12 @@ Local<Value> OpenFile(const Arguments& args) {
723734
string path = args[0].toStr();
724735
std::optional<std::string> dirPath = getDirectoryPath(path);
725736
if (dirPath.has_value()) {
726-
std::filesystem::create_directory(dirPath.value());
737+
std::error_code code;
738+
std::filesystem::create_directories(dirPath.value(), code);
739+
if (code) {
740+
LOG_ERROR_WITH_SCRIPT_INFO("Fail to create directory " + dirPath.value() + "!\n");
741+
return Boolean::newBoolean(false);
742+
}
727743
} else {
728744
LOG_ERROR_WITH_SCRIPT_INFO("Fail to create directory " + dirPath.value() + "!\n");
729745
return {};

src/legacy/utils/JsonHelper.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ inline ordered_json CreateJson(const std::string& path, const std::string& defCo
1919
std::size_t pos = path.find_last_of('/');
2020
if (pos != std::string::npos) {
2121
std::string dirPath = path.substr(0, pos);
22-
std::filesystem::create_directory(dirPath);
22+
std::filesystem::create_directories(dirPath);
2323
}
2424
} else if (path.find('\\') != std::string::npos) { // e.g. plugins\\LeviLamina\\LeviLamina.json
2525
std::size_t pos = path.find_last_of('\\');
2626
if (pos != std::string::npos) {
2727
std::string dirPath = path.substr(0, pos);
28-
std::filesystem::create_directory(dirPath);
28+
std::filesystem::create_directories(dirPath);
2929
}
3030
} else {
3131
lse::getSelfPluginInstance().getLogger().error("Fail in create json file!");

tooth.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"format_version": 2,
33
"tooth": "github.com/LiteLDev/LegacyScriptEngine",
4-
"version": "0.4.10",
4+
"version": "0.4.11",
55
"info": {
66
"name": "LegacyScriptEngine",
77
"description": "A plugin engine for running LLSE plugins on LeviLamina",
@@ -12,7 +12,7 @@
1212
]
1313
},
1414
"dependencies": {
15-
"gitea.litebds.com/LiteLDev/legacy-script-engine-lua": "0.4.10",
16-
"gitea.litebds.com/LiteLDev/legacy-script-engine-quickjs": "0.4.10"
15+
"gitea.litebds.com/LiteLDev/legacy-script-engine-lua": "0.4.11",
16+
"gitea.litebds.com/LiteLDev/legacy-script-engine-quickjs": "0.4.11"
1717
}
1818
}

tooth.lua.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"format_version": 2,
33
"tooth": "gitea.litebds.com/LiteLDev/legacy-script-engine-lua",
4-
"version": "0.4.10",
4+
"version": "0.4.11",
55
"info": {
66
"name": "LegacyScriptEngine with Lua backend",
77
"description": "A plugin engine for running LLSE plugins on LeviLamina",

tooth.nodejs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"format_version": 2,
33
"tooth": "gitea.litebds.com/LiteLDev/legacy-script-engine-nodejs",
4-
"version": "0.4.10",
4+
"version": "0.4.11",
55
"info": {
66
"name": "LegacyScriptEngine with NodeJs backend",
77
"description": "A plugin engine for running LLSE plugins on LeviLamina",

tooth.python.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"format_version": 2,
33
"tooth": "gitea.litebds.com/LiteLDev/legacy-script-engine-python",
4-
"version": "0.4.10",
4+
"version": "0.4.11",
55
"info": {
66
"name": "LegacyScriptEngine with Python backend",
77
"description": "A plugin engine for running LLSE plugins on LeviLamina",

tooth.quickjs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"format_version": 2,
33
"tooth": "gitea.litebds.com/LiteLDev/legacy-script-engine-quickjs",
4-
"version": "0.4.10",
4+
"version": "0.4.11",
55
"info": {
66
"name": "LegacyScriptEngine with QuickJs backend",
77
"description": "A plugin engine for running LLSE plugins on LeviLamina",

0 commit comments

Comments
 (0)