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 00000000..a08d2d17 Binary files /dev/null and b/project/dl_console/res/icon/00030.png differ diff --git a/project/dl_console/res/icon/00031.png b/project/dl_console/res/icon/00031.png new file mode 100644 index 00000000..1a1ea6e3 Binary files /dev/null and b/project/dl_console/res/icon/00031.png differ 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