Skip to content

Commit 679df12

Browse files
committed
bugfix : lfs.dir
1 parent 5a01557 commit 679df12

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/lfs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ utf8_filename(lua_State *L, const wchar_t * winfilename, int wsz, char *utf8buff
4040
sz = WideCharToMultiByte(CP_UTF8, 0, winfilename, wsz, utf8buffer, sz, NULL, NULL);
4141
if (sz == 0)
4242
return luaL_error(L, "convert to utf-8 filename fail");
43-
return sz;
43+
// not include end \0
44+
return sz - 1;
4445
}
4546

4647
#define DIR_METATABLE "SOLUNA_DIR"
@@ -55,7 +56,7 @@ windows_filename(lua_State *L, const char * utf8filename, int usz, wchar_t * win
5556
wsz = MultiByteToWideChar(CP_UTF8, 0, utf8filename, usz, winbuffer, wsz);
5657
if (wsz == 0)
5758
return luaL_error(L, "convert to windows utf-16 filename fail");
58-
return wsz;
59+
return wsz - 1;
5960
}
6061

6162
static void
@@ -95,7 +96,6 @@ static void
9596
push_filename(lua_State *L, WIN32_FIND_DATAW *data) {
9697
char firstname[LONGPATH_MAX];
9798
int ulen = utf8_filename(L, data->cFileName, -1, firstname, LONGPATH_MAX);
98-
9999
lua_pushlstring(L, firstname, ulen);
100100
}
101101

0 commit comments

Comments
 (0)