diff --git a/binding/lua_filesystem.cpp b/binding/lua_filesystem.cpp index a8b3db87..04dcdecd 100644 --- a/binding/lua_filesystem.cpp +++ b/binding/lua_filesystem.cpp @@ -254,7 +254,9 @@ namespace bee::lua_filesystem { static int extension(lua_State* L) { path_ptr self = getpathptr(L, 1); - push(L, self->extension()); + auto u8str = self->extension().generic_u8string(); + auto str = u8tostrview(u8str); + lua_pushlstring(L, str.data(), str.size()); return 1; } @@ -292,23 +294,6 @@ namespace bee::lua_filesystem { return 1; } - static int equal_extension(lua_State* L) { - path_ptr self = getpathptr(L, 1); - path_ptr path = getpathptr(L, 2); - auto selfext = self->extension(); - auto pathext = path->native(); - if (selfext.empty()) { - lua_pushboolean(L, pathext.empty()); - return 1; - } - if (pathext[0] != '.') { - lua_pushboolean(L, path_helper::equal(selfext, fs::path::string_type { '.' } + pathext)); - return 1; - } - lua_pushboolean(L, path_helper::equal(selfext, pathext)); - return 1; - } - static int lexically_normal(lua_State* L) { path_ptr self = getpathptr(L, 1); push(L, self->lexically_normal()); @@ -356,7 +341,6 @@ namespace bee::lua_filesystem { { "remove_filename", remove_filename }, { "replace_filename", replace_filename }, { "replace_extension", replace_extension }, - { "equal_extension", equal_extension }, { "lexically_normal", lexically_normal }, { NULL, NULL }, }; diff --git a/test/test_filesystem.lua b/test/test_filesystem.lua index 432b2e51..b2673d05 100644 --- a/test/test_filesystem.lua +++ b/test/test_filesystem.lua @@ -108,7 +108,7 @@ end function test_fs:test_extension() local function get_extension(path) - return fs.path(path):extension():string() + return fs.path(path):extension() end lt.assertEquals(get_extension("a/b/c.ext"), ".ext") lt.assertEquals(get_extension("a/b/c"), "") @@ -192,20 +192,6 @@ function test_fs:test_replace_extension() lt.assertEquals(replace_extension("c.ext", ".lua"), "c.lua") end -function test_fs:test_equal_extension() - local function equal_extension(path, ext) - return lt.assertEquals(fs.path(path):equal_extension(ext), true) - end - equal_extension("a/b/c.ext", ".ext") - equal_extension("a/b/c.ext", "ext") - equal_extension("a/b/c", "") - equal_extension("a/b/.ext", "") - equal_extension("a/b/c.", ".") - equal_extension("a/b/c..", ".") - equal_extension("a/b/c..lua", ".lua") - equal_extension("a/b/c..lua", "lua") -end - function test_fs:test_get_permissions() local filename = "temp.txt" create_file(filename)