修复lfs.symlinkattributes
This commit is contained in:
parent
8d9d8fc975
commit
e9fd312fda
|
@ -1180,39 +1180,47 @@ int luaopen_lfs(lua_State * L)
|
|||
//set_info(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
#if defined(_WIN32)
|
||||
void UTF8ToUnicode(const char* UTF8, WCHAR* UNI) {
|
||||
void UTF8ToUnicode(const char* UTF8, WCHAR* UNI)
|
||||
{
|
||||
int len = MultiByteToWideChar(CP_UTF8, 0, UTF8, -1, NULL, 0);
|
||||
MultiByteToWideChar(CP_UTF8, 0, UTF8, -1, UNI, len);
|
||||
}
|
||||
|
||||
void UnicodeToUTF8(const WCHAR* UNI, char* UTF8) {
|
||||
void UnicodeToUTF8(const WCHAR* UNI, char* UTF8)
|
||||
{
|
||||
int len = WideCharToMultiByte(CP_UTF8, 0, UNI, -1, NULL, 0, NULL, NULL);
|
||||
WideCharToMultiByte(CP_UTF8, 0, UNI, -1, UTF8, len, NULL, NULL);
|
||||
}
|
||||
|
||||
int utf8_stat(const char* _FileName, struct _stat64* _Stat) {
|
||||
int utf8_stat(const char* _FileName, struct _stat64* _Stat)
|
||||
{
|
||||
WCHAR FileName[MAX_PATH];
|
||||
memset(FileName, 0, sizeof(FileName));
|
||||
UTF8ToUnicode(_FileName, FileName);
|
||||
return _wstat64(FileName, _Stat);
|
||||
}
|
||||
|
||||
int utf8_chdir(const char* _Path) {
|
||||
int utf8_chdir(const char* _Path)
|
||||
{
|
||||
WCHAR Path[MAX_PATH];
|
||||
memset(Path, 0, sizeof(Path));
|
||||
UTF8ToUnicode(_Path, Path);
|
||||
return _wchdir(Path);
|
||||
}
|
||||
|
||||
int utf8_mkdir(const char* _Path) {
|
||||
int utf8_mkdir(const char* _Path)
|
||||
{
|
||||
WCHAR Path[MAX_PATH];
|
||||
memset(Path, 0, sizeof(Path));
|
||||
UTF8ToUnicode(_Path, Path);
|
||||
return _wmkdir(Path);
|
||||
}
|
||||
|
||||
char* utf8_getcwd(char* _DstBuf, int _SizeInBytes) {
|
||||
char* utf8_getcwd(char* _DstBuf, int _SizeInBytes)
|
||||
{
|
||||
WCHAR Buf[MAX_PATH];
|
||||
memset(Buf, 0, sizeof(Buf));
|
||||
WCHAR* uni = _wgetcwd(Buf, MAX_PATH);
|
||||
|
@ -1223,7 +1231,8 @@ char* utf8_getcwd(char* _DstBuf, int _SizeInBytes) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
intptr_t utf8_findfirst(const char* _FileName, struct utf8_finddata* _FindData) {
|
||||
intptr_t utf8_findfirst(const char* _FileName, struct utf8_finddata* _FindData)
|
||||
{
|
||||
WCHAR FileName[MAX_PATH];
|
||||
memset(FileName, 0, sizeof(FileName));
|
||||
UTF8ToUnicode(_FileName, FileName);
|
||||
|
@ -1232,13 +1241,15 @@ intptr_t utf8_findfirst(const char* _FileName, struct utf8_finddata* _FindData)
|
|||
return r;
|
||||
}
|
||||
|
||||
int utf8_findnext(intptr_t _FindHandle, struct utf8_finddata* _FindData) {
|
||||
int utf8_findnext(intptr_t _FindHandle, struct utf8_finddata* _FindData)
|
||||
{
|
||||
int r = _wfindnext(_FindHandle, &_FindData->data);
|
||||
UnicodeToUTF8(_FindData->data.name, _FindData->name);
|
||||
return r;
|
||||
}
|
||||
|
||||
BOOLEAN utf8_CreateSymbolicLink(LPCSTR lpSymlinkFileName, LPCSTR lpTargetFileName, DWORD dwFlags) {
|
||||
BOOLEAN utf8_CreateSymbolicLink(LPCSTR lpSymlinkFileName, LPCSTR lpTargetFileName, DWORD dwFlags)
|
||||
{
|
||||
WCHAR FileName[MAX_PATH];
|
||||
memset(FileName, 0, sizeof(FileName));
|
||||
UTF8ToUnicode(lpSymlinkFileName, FileName);
|
||||
|
@ -1248,7 +1259,8 @@ BOOLEAN utf8_CreateSymbolicLink(LPCSTR lpSymlinkFileName, LPCSTR lpTargetFileNam
|
|||
return CreateSymbolicLinkW(FileName, FileName2,dwFlags);
|
||||
}
|
||||
|
||||
BOOLEAN utf8_CreateHardLink(LPCSTR lpFileName, LPCSTR lpExistingFileName, LPSECURITY_ATTRIBUTES lpSecurityAttributes) {
|
||||
BOOLEAN utf8_CreateHardLink(LPCSTR lpFileName, LPCSTR lpExistingFileName, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
|
||||
{
|
||||
WCHAR FileName[MAX_PATH];
|
||||
memset(FileName, 0, sizeof(FileName));
|
||||
UTF8ToUnicode(lpFileName, FileName);
|
||||
|
@ -1258,8 +1270,7 @@ BOOLEAN utf8_CreateHardLink(LPCSTR lpFileName, LPCSTR lpExistingFileName, LPSECU
|
|||
return CreateHardLinkW(FileName, FileName2, lpSecurityAttributes);
|
||||
}
|
||||
|
||||
HANDLE utf8_CreateFile(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES
|
||||
lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
|
||||
HANDLE utf8_CreateFile(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
|
||||
{
|
||||
WCHAR FileName[MAX_PATH];
|
||||
memset(FileName, 0, sizeof(FileName));
|
||||
|
@ -1267,7 +1278,8 @@ HANDLE utf8_CreateFile(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMo
|
|||
return CreateFileW(FileName, dwDesiredAccess, dwShareMode,lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
|
||||
}
|
||||
|
||||
DWORD utf8_GetFinalPathNameByHandle(HANDLE hFile, LPSTR lpszFilePath, DWORD cchFilePath, DWORD dwFlags) {
|
||||
DWORD utf8_GetFinalPathNameByHandle(HANDLE hFile, LPSTR lpszFilePath, DWORD cchFilePath, DWORD dwFlags)
|
||||
{
|
||||
WCHAR Buf[MAX_PATH];
|
||||
memset(Buf, 0, sizeof(Buf));
|
||||
DWORD r = GetFinalPathNameByHandleW(hFile, Buf, MAX_PATH, dwFlags);
|
||||
|
@ -1277,6 +1289,15 @@ DWORD utf8_GetFinalPathNameByHandle(HANDLE hFile, LPSTR lpszFilePath, DWORD cchF
|
|||
return r;
|
||||
}
|
||||
|
||||
BOOL utf8_GetFileAttributesExW(LPCWSTR lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, LPVOID lpFileInformation)
|
||||
{
|
||||
WCHAR FileName[MAX_PATH];
|
||||
memset(FileName, 0, sizeof(FileName));
|
||||
UTF8ToUnicode(lpFileName, FileName);
|
||||
BOOL r = GetFileAttributesExW(lpFileName, fInfoLevelId , lpFileInformation);
|
||||
return r;
|
||||
}
|
||||
|
||||
int utf8_utime(const char* _FileName, const struct utimbuf* _Time) {
|
||||
WCHAR Path[MAX_PATH];
|
||||
memset(Path, 0, sizeof(Path));
|
||||
|
|
|
@ -39,40 +39,54 @@ LUALIB_API int luaopen_lfs(lua_State * L);
|
|||
#include <wchar.h>
|
||||
#include <windows.h>
|
||||
|
||||
struct utf8_finddata
|
||||
{
|
||||
struct _wfinddata_t data;
|
||||
char name[260];
|
||||
}c_file;
|
||||
|
||||
int utf8_stat(const char* _FileName, struct _stat64* _Stat);
|
||||
int utf8_chdir(const char* _Path);
|
||||
int utf8_mkdir(const char* _Path);
|
||||
char* utf8_getcwd(char* _DstBuf, int _SizeInBytes);
|
||||
struct utf8_finddata
|
||||
{
|
||||
struct _wfinddata_t data;
|
||||
char name[260];
|
||||
}c_file;
|
||||
intptr_t utf8_findfirst(const char* _FileName, struct utf8_finddata* _FindData);
|
||||
int utf8_findnext(intptr_t _FindHandle, struct utf8_finddata* _FindData);
|
||||
BOOLEAN utf8_CreateSymbolicLink(LPCSTR lpSymlinkFileName, LPCSTR lpTargetFileName, DWORD dwFlags);
|
||||
BOOLEAN utf8_CreateHardLink(LPCSTR lpFileName, LPCSTR lpExistingFileName, LPSECURITY_ATTRIBUTES lpSecurityAttributes);
|
||||
HANDLE utf8_CreateFile(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES
|
||||
lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
|
||||
DWORD utf8_GetFinalPathNameByHandle(HANDLE hFile, LPSTR lpszFilePath, DWORD cchFilePath, DWORD dwFlags);
|
||||
int utf8_utime(const char * _FileName, const struct utimbuf* _Time);
|
||||
int utf8_utime(const char* _FileName, const struct utimbuf* _Time);
|
||||
|
||||
#define STAT_FUNC utf8_stat
|
||||
#define chdir(p) (utf8_chdir(p))
|
||||
#define getcwd(d, s) (utf8_getcwd(d, s))
|
||||
#define lfs_mkdir utf8_mkdir
|
||||
#define rmdir(p) (_rmdir(p))
|
||||
#define utime utf8_utime
|
||||
|
||||
#undef _findfirst
|
||||
#define _findfirst utf8_findfirst
|
||||
|
||||
#undef _findnext
|
||||
#define _findnext utf8_findnext
|
||||
|
||||
BOOLEAN utf8_CreateSymbolicLink(LPCSTR lpSymlinkFileName, LPCSTR lpTargetFileName, DWORD dwFlags);
|
||||
BOOLEAN utf8_CreateHardLink(LPCSTR lpFileName, LPCSTR lpExistingFileName, LPSECURITY_ATTRIBUTES lpSecurityAttributes);
|
||||
HANDLE utf8_CreateFile(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
|
||||
DWORD utf8_GetFinalPathNameByHandle(HANDLE hFile, LPSTR lpszFilePath, DWORD cchFilePath, DWORD dwFlags);
|
||||
BOOL utf8_GetFileAttributesExW(LPCWSTR lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, LPVOID lpFileInformation);
|
||||
|
||||
|
||||
#undef CreateSymbolicLink
|
||||
#define CreateSymbolicLink utf8_CreateSymbolicLink
|
||||
|
||||
#undef CreateHardLink
|
||||
#define CreateHardLink utf8_CreateHardLink
|
||||
#define lfs_mkdir utf8_mkdir
|
||||
#define rmdir(p) (_rmdir(p))
|
||||
|
||||
#undef CreateFile
|
||||
#define CreateFile utf8_CreateFile
|
||||
|
||||
#undef GetFinalPathNameByHandle
|
||||
#define GetFinalPathNameByHandle utf8_GetFinalPathNameByHandle
|
||||
#define utime utf8_utime
|
||||
|
||||
#undef GetFileAttributesEx
|
||||
#define GetFileAttributesEx utf8_GetFileAttributesExW
|
||||
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue