From f079fa635f0b5a4dfdeda17ce920e8a2ff9a1efa Mon Sep 17 00:00:00 2001 From: lveyoupad <1339484752@qq.com> Date: Fri, 15 Aug 2025 00:14:42 +0800 Subject: [PATCH] =?UTF-8?q?*=20dl=20shell=20=E6=89=B9=E9=87=8F=E5=B0=8F?= =?UTF-8?q?=E5=86=99=E6=96=87=E4=BB=B6=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dl/io/dl_file.cpp | 3 ++- dl/io/dl_file.h | 27 ++++++++++++++++++- dl/io/dl_svn.cpp | 2 +- dl/script/dl_lua_register.cpp | 22 ++++++++++++--- project/dl_console/res/.vscode/settings.json | 6 +++++ project/dl_console/res/icon/00030.png | Bin 0 -> 359 bytes project/dl_console/res/icon/00031.png | Bin 0 -> 343 bytes project/dl_console/res/批量小写文件名.lua | 13 +++++++++ project/dl_editor | 2 +- project/dl_midi | 2 +- project/hs | 2 +- 11 files changed, 69 insertions(+), 10 deletions(-) create mode 100644 project/dl_console/res/.vscode/settings.json create mode 100644 project/dl_console/res/icon/00030.png create mode 100644 project/dl_console/res/icon/00031.png diff --git a/dl/io/dl_file.cpp b/dl/io/dl_file.cpp index 57c58498..994d7b77 100644 --- a/dl/io/dl_file.cpp +++ b/dl/io/dl_file.cpp @@ -625,7 +625,7 @@ std::string GetExtension(std::string_view path_name, bool has_dot /*= false*/) return {}; } -std::string GetFilename(std::string_view path_name) +std::string GetFileName(std::string_view path_name) { try { @@ -1002,4 +1002,5 @@ bool Rename(std::string_view src, std::string_view tar) return false; } + } \ No newline at end of file diff --git a/dl/io/dl_file.h b/dl/io/dl_file.h index 79331260..be92f955 100644 --- a/dl/io/dl_file.h +++ b/dl/io/dl_file.h @@ -51,6 +51,7 @@ namespace dl::File void GetPathFileAll(std::string_view path, std::vector& ret, std::string_view regex = "", bool recursion = true); + /** * @brief 获取文件夹当前内容 * @param[in] path 路径 @@ -233,7 +234,7 @@ std::string GetExtension(std::string_view path_name, bool has_dot = false); * @param[in] path_name * @note a/b返回b,a/b/返回空 */ -std::string GetFilename(std::string_view path_name); +std::string GetFileName(std::string_view path_name); /** * @brief 返回文件名不含后缀 * @param[in] path_name @@ -346,4 +347,28 @@ std::string PathPublic(); void InitFileSystem(); + +namespace Lua +{ + inline std::vector lua_GetPathFileAll_3(std::string_view path, std::string_view regex /*= ""*/, bool recursion /*= true*/) + { + std::vector ret; + GetPathFileAll(path, ret, regex, recursion); + return ret; + } + inline std::vector lua_GetPathFileAll_2(std::string_view path, + std::string_view regex) + { + std::vector ret; + GetPathFileAll(path, ret, regex, true); + return ret; + } + inline std::vector lua_GetPathFileAll_1(std::string_view path) + { + std::vector ret; + GetPathFileAll(path, ret, "", true); + return ret; + } +} + } \ No newline at end of file diff --git a/dl/io/dl_svn.cpp b/dl/io/dl_svn.cpp index 2a095229..3b8ebe67 100644 --- a/dl/io/dl_svn.cpp +++ b/dl/io/dl_svn.cpp @@ -218,7 +218,7 @@ namespace dl { _exe = svn_path; if (!dl::File::IsExist(_exe) - || dl::File::GetFilename(svn_path) != "svn.exe") + || dl::File::GetFileName(svn_path) != "svn.exe") return false; return true; } diff --git a/dl/script/dl_lua_register.cpp b/dl/script/dl_lua_register.cpp index 96d5dcf2..c8a15edb 100644 --- a/dl/script/dl_lua_register.cpp +++ b/dl/script/dl_lua_register.cpp @@ -7,6 +7,7 @@ #include "ui/dl_ui_manager.h" #include +#include namespace dl { @@ -37,7 +38,19 @@ namespace dl .endClass(); auto result = luabridge::push(L, g_system); - lua_setglobal(L, "system"); + lua_setglobal(L, "g_system"); + } + + void lua_register_file(lua_State* L) + { + using namespace File::Lua; + luabridge::getGlobalNamespace(L) + .beginNamespace("g_file") + .addFunction("GetPathFileAll", &lua_GetPathFileAll_3, &lua_GetPathFileAll_2, &lua_GetPathFileAll_1) + .addFunction("Rename", &File::Rename) + .addFunction("GetFilePath", &File::GetFilePath) + .addFunction("GetFileName", &File::GetFileName) + .endNamespace(); } void lua_register_gfx(lua_State* L) @@ -48,7 +61,7 @@ namespace dl .endClass(); auto result = luabridge::push(L, g_gfx); - lua_setglobal(L, "gfx"); + lua_setglobal(L, "g_gfx"); } void lua_register_ui(lua_State* L) @@ -73,7 +86,7 @@ namespace dl .endClass(); auto result = luabridge::push(L, g_ui); - lua_setglobal(L, "ui"); + lua_setglobal(L, "g_ui"); } void lua_register_factory(lua_State* L) @@ -84,7 +97,7 @@ namespace dl .endClass(); auto result = luabridge::push(L, g_factory); - lua_setglobal(L, "factory");*/ + lua_setglobal(L, "g_factory");*/ } #if DL_PLATFORM == DL_PLATFORM_WIN32 @@ -102,6 +115,7 @@ namespace dl { lua_register_base(L); lua_register_system(L); + lua_register_file(L); lua_register_gfx(L); lua_register_ui(L); lua_register_factory(L); diff --git a/project/dl_console/res/.vscode/settings.json b/project/dl_console/res/.vscode/settings.json new file mode 100644 index 00000000..585e052b --- /dev/null +++ b/project/dl_console/res/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "Lua.diagnostics.globals": [ + "g_file", + "system" + ] +} \ No newline at end of file diff --git a/project/dl_console/res/icon/00030.png b/project/dl_console/res/icon/00030.png new file mode 100644 index 0000000000000000000000000000000000000000..a08d2d171d2ddd7a641449b285849cacb298b575 GIT binary patch literal 359 zcmV-t0hs=YP)svqp#47=U`=IY)6Dt6f==d$%04*kb{I&SE^LAB?FSZ)muH{ zCfVY}oPrIyx@E z!m)&mHAd$J`ztzRtUWqR%t=-QSJijBG#2X;9Rk)py0O^5Q-_B2jcy=T&%#;(>(BJV z21nNqdrD(*cU6?du;{vCVe&wOKx{;@-7Rj}_~%br8ggg;B6ecURuRfCtpN*{A)E$K z%Ji8ZY=9*-U@@Cl>s1^1#&7Nu+yz9AqSGISXR#ZHB+Jp4D*4%yEERu@%mLC@>0^U` zVb@bySlFMOu~iP#O)A4MrsAOAP*

sBA9#B?kc zRC`KzD{y{S71;OKiBnLprmlvAF$%z|xeB{+aiem-~B pTuAz%vIU^5v~6v)S1^sLegI!4i`~IPCAa_p002ovPDHLkV1nagjV=HH literal 0 HcmV?d00001 diff --git a/project/dl_console/res/批量小写文件名.lua b/project/dl_console/res/批量小写文件名.lua index 91ed3a96..744e0932 100644 --- a/project/dl_console/res/批量小写文件名.lua +++ b/project/dl_console/res/批量小写文件名.lua @@ -1,3 +1,16 @@ +local ret_files = g_file.GetPathFileAll("./") + +for key, value in pairs(ret_files) do + + + local path = g_file.GetFilePath(value) + local filename = g_file.GetFileName(value) + local new_name = path .. string.lower(filename) + g_file.Rename(value, new_name) + + print(value.."->"..new_name) +end + print "此工具会批量修改当前文件夹的所有文件名为小写" system "pause" \ No newline at end of file diff --git a/project/dl_editor b/project/dl_editor index e82fc28d..c1f40dc2 160000 --- a/project/dl_editor +++ b/project/dl_editor @@ -1 +1 @@ -Subproject commit e82fc28dfaaca8fc66eb10641948d345b40684e8 +Subproject commit c1f40dc23726e09a40538ec616cb9fdc7cabc3e7 diff --git a/project/dl_midi b/project/dl_midi index e2f90f11..eef4879b 160000 --- a/project/dl_midi +++ b/project/dl_midi @@ -1 +1 @@ -Subproject commit e2f90f117f767a7e1bc6f9b5ab5706c4702346b4 +Subproject commit eef4879b9356e7b1170658ded5f1d443732902f7 diff --git a/project/hs b/project/hs index 2f1c5475..1e3af2b9 160000 --- a/project/hs +++ b/project/hs @@ -1 +1 @@ -Subproject commit 2f1c5475d9317850bb42ae69734bf620921bd64c +Subproject commit 1e3af2b9e499b02d9bd29472bf7cc463f142bd1b