Skip to content

Commit 991acad

Browse files
committed
refactor: remove lse::legacy::GetFileNameList
refactor: remove legacyapi/Base64.h fix: fix mysql support
1 parent d957e80 commit 991acad

File tree

12 files changed

+988
-1053
lines changed

12 files changed

+988
-1053
lines changed

src/legacy/api/DataAPI.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@
77
#include <string>
88
#include <vector>
99

10-
#include "legacyapi/Base64.h"
11-
#include "legacyapi/utils/FileHelper.h"
10+
#include "ll/api/utils/Base64Utils.h"
1211
#include "ll/api/io/FileUtils.h"
1312
#include "ll/api/service/Bedrock.h"
1413
#include "ll/api/service/PlayerInfo.h"
1514
#include "ll/api/utils/StringUtils.h"
1615
#include "main/EconomicSystem.h"
1716
#include "mc/deps/crypto/hash/Hash.h"
18-
#include "mc/world/actor/player/Player.h"
1917
#include "utils/JsonHelper.h"
2018

2119
//////////////////// Class Definition ////////////////////
@@ -924,7 +922,7 @@ Local<Value> DataClass::toBase64(const Arguments& args) {
924922
LOG_WRONG_ARG_TYPE(__FUNCTION__);
925923
return Local<Value>();
926924
}
927-
return String::newString(Base64::Encode(data));
925+
return String::newString(ll::base64_utils::encode(data));
928926
}
929927
CATCH("Fail in ToBase64!");
930928
}
@@ -939,7 +937,7 @@ Local<Value> DataClass::fromBase64(const Arguments& args) {
939937
CHECK_ARG_TYPE(args[1], ValueKind::kBoolean);
940938
isBinary = args[1].asBoolean().value();
941939
}
942-
auto data = Base64::Decode(args[0].asString().toString());
940+
auto data = ll::base64_utils::decode(args[0].asString().toString());
943941
if (isBinary) {
944942
return ByteBuffer::newByteBuffer((void*)data.c_str(), data.size());
945943
} else {

src/legacy/api/FileSystemAPI.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ Local<Value> CheckIsDir(const Arguments& args) {
612612
LOG_ERROR_WITH_SCRIPT_INFO(__FUNCTION__, "Fail to Get Type of " + args[0].asString().toString() + "!\n");
613613
return {};
614614
}
615-
CATCH("Fail in GetFilesList!");
615+
CATCH("Fail in CheckIsDir!");
616616
}
617617

618618
Local<Value> GetFileSize(const Arguments& args) {
@@ -630,15 +630,22 @@ Local<Value> GetFileSize(const Arguments& args) {
630630
LOG_ERROR_WITH_SCRIPT_INFO(__FUNCTION__, "Fail to Get Size of " + args[0].asString().toString() + "!\n");
631631
return {};
632632
}
633-
CATCH("Fail in GetFilesList!");
633+
CATCH("Fail in GetFileSize!");
634634
}
635635

636636
Local<Value> GetFilesList(const Arguments& args) {
637637
CHECK_ARGS_COUNT(args, 1);
638638
CHECK_ARG_TYPE(args[0], ValueKind::kString);
639639

640640
try {
641-
auto fileList = lse::legacy::GetFileNameList(args[0].asString().toString());
641+
std::filesystem::directory_entry directory(args[0].asString().toU8string());
642+
if (!directory.is_directory()) return {};
643+
644+
std::vector<std::string> fileList;
645+
std::filesystem::directory_iterator deps(directory);
646+
for (auto& i : deps) {
647+
fileList.push_back(ll::string_utils::u8str2str(i.path().filename().u8string()));
648+
}
642649

643650
Local<Array> arr = Array::newArray();
644651
for (auto& file : fileList) arr.add(String::newString(file));

src/legacy/api/NbtAPI.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "api/NbtAPI.h"
22

33
#include "api/APIHelp.h"
4-
#include "legacyapi/Base64.h"
4+
#include "ll/api/utils/Base64Utils.h"
55
#include "mc/nbt/ByteArrayTag.h"
66
#include "mc/nbt/ByteTag.h"
77
#include "mc/nbt/CompoundTag.h"
@@ -16,7 +16,6 @@
1616
#include "mc/nbt/StringTag.h"
1717

1818
#include <magic_enum.hpp>
19-
#include <mc/nbt/CompoundTag.h>
2019
#include <memory>
2120
#include <string>
2221
#include <string_view>
@@ -193,7 +192,7 @@ void TagToJson_List_Helper(ordered_json& res, ListTag* nbt) {
193192
for (unsigned int i = 0; i < bytes.size(); ++i) {
194193
tmpData[i] = bytes[i];
195194
}
196-
res.push_back(Base64::Encode(tmpData));
195+
res.push_back(ll::base64_utils::encode(tmpData));
197196
break;
198197
}
199198
case Tag::Type::List: {
@@ -248,7 +247,7 @@ void TagToJson_Compound_Helper(ordered_json& res, CompoundTag* nbt) {
248247
for (unsigned int i = 0; i < bytes.size(); ++i) {
249248
tmpData[i] = bytes[i];
250249
}
251-
res.push_back(Base64::Encode(tmpData));
250+
res.push_back(ll::base64_utils::encode(tmpData));
252251
break;
253252
}
254253
case Tag::Type::List: {
@@ -304,7 +303,7 @@ std::string TagToJson(Tag* nbt, int formatIndent) {
304303
for (uchar data : bytes) {
305304
tmpData.push_back(data);
306305
}
307-
result = Base64::Encode(tmpData);
306+
result = ll::base64_utils::encode(tmpData);
308307
break;
309308
}
310309
case Tag::Type::List: {

src/legacy/legacyapi/Base64.h

Lines changed: 0 additions & 108 deletions
This file was deleted.

src/legacy/legacyapi/db/Session.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ SharedPointer<Session> Session::_Create(DBType type, const ConnParams& params) {
107107
case DBType::SQLite:
108108
session = params.empty() ? new SQLiteSession() : new SQLiteSession(params);
109109
break;
110-
// case DBType::MySQL:
111-
// session = params.empty() ? new MySQLSession() : new MySQLSession(params);
112-
// break;
110+
case DBType::MySQL:
111+
session = params.empty() ? new MySQLSession() : new MySQLSession(params);
112+
break;
113113
default:
114114
throw std::runtime_error("Session::_Create: Unknown/Unsupported database type");
115115
}

0 commit comments

Comments
 (0)