mirror of
https://github.com/FEX-Emu/FEX.git
synced 2025-02-02 20:44:30 +00:00
Merge pull request #3978 from bylaws/create
Windows: Implement CreateDirectoryW CRT function
This commit is contained in:
commit
eadb502059
@ -35,6 +35,8 @@ class ScopedUnicodeString {
|
||||
private:
|
||||
UNICODE_STRING Str {};
|
||||
public:
|
||||
ScopedUnicodeString() = default;
|
||||
|
||||
ScopedUnicodeString(const char* AStr) {
|
||||
RtlCreateUnicodeStringFromAsciiz(&Str, AStr);
|
||||
}
|
||||
@ -42,6 +44,7 @@ public:
|
||||
~ScopedUnicodeString() {
|
||||
RtlFreeUnicodeString(&Str);
|
||||
}
|
||||
|
||||
UNICODE_STRING* operator->() {
|
||||
return &Str;
|
||||
}
|
||||
|
@ -49,14 +49,14 @@ DLLEXPORT_FUNC(HANDLE, CreateFileW,
|
||||
UNICODE_STRING PathW;
|
||||
RtlInitUnicodeString(&PathW, lpFileName);
|
||||
|
||||
UNICODE_STRING NTPath;
|
||||
if (!RtlDosPathNameToNtPathName_U(PathW.Buffer, &NTPath, nullptr, nullptr)) {
|
||||
ScopedUnicodeString NTPath;
|
||||
if (!RtlDosPathNameToNtPathName_U(PathW.Buffer, &*NTPath, nullptr, nullptr)) {
|
||||
SetLastError(ERROR_PATH_NOT_FOUND);
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
OBJECT_ATTRIBUTES ObjAttributes;
|
||||
InitializeObjectAttributes(&ObjAttributes, &NTPath, OBJ_CASE_INSENSITIVE, nullptr, nullptr);
|
||||
InitializeObjectAttributes(&ObjAttributes, &*NTPath, OBJ_CASE_INSENSITIVE, nullptr, nullptr);
|
||||
|
||||
HANDLE Handle;
|
||||
IO_STATUS_BLOCK IOSB;
|
||||
@ -156,7 +156,23 @@ DLLEXPORT_FUNC(WINBOOL, CreateDirectoryA, (LPCSTR lpPathName, LPSECURITY_ATTRIBU
|
||||
}
|
||||
|
||||
DLLEXPORT_FUNC(WINBOOL, CreateDirectoryW, (LPCWSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes)) {
|
||||
UNIMPLEMENTED();
|
||||
UNICODE_STRING PathW;
|
||||
RtlInitUnicodeString(&PathW, lpPathName);
|
||||
|
||||
ScopedUnicodeString NTPath;
|
||||
if (!RtlDosPathNameToNtPathName_U(PathW.Buffer, &*NTPath, nullptr, nullptr)) {
|
||||
SetLastError(ERROR_PATH_NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
|
||||
OBJECT_ATTRIBUTES ObjAttributes;
|
||||
InitializeObjectAttributes(&ObjAttributes, &*NTPath, OBJ_CASE_INSENSITIVE, nullptr, nullptr);
|
||||
|
||||
HANDLE Handle;
|
||||
IO_STATUS_BLOCK IOSB;
|
||||
NTSTATUS Status = NtCreateFile(&Handle, GENERIC_READ | SYNCHRONIZE, &ObjAttributes, &IOSB, nullptr, FILE_ATTRIBUTE_NORMAL,
|
||||
FILE_SHARE_READ, FILE_CREATE, FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT, nullptr, 0);
|
||||
return WinAPIReturn(Status);
|
||||
}
|
||||
|
||||
DLLEXPORT_FUNC(WINBOOL, GetFileInformationByHandle, (HANDLE hFile, LPBY_HANDLE_FILE_INFORMATION lpFileInformation)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user