Make os.stat unicode-aware
int os_stat(lua_State* L)
{
+ const char* filename = luaL_checkstring(L, 1);
+
+#if PLATFORM_WINDOWS
+ struct _stat64i32 s;
+
+ wchar_t wide_filename[PATH_MAX];
+ if (MultiByteToWideChar(CP_UTF8, 0, filename, -1, wide_filename, PATH_MAX) == 0)
+ {
+ lua_pushstring(L, "unable to encode source path");
+ return lua_error(L);
+ }
+
+ if (_wstat(wide_filename, &s) != 0)
+#else
struct stat s;
- const char* filename = luaL_checkstring(L, 1);
if (stat(filename, &s) != 0)
+#endif
{
lua_pushnil(L);
switch (errno)
