From: Dmitry Timoshkov dmitry@baikal.ru
Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/kernel32/tests/file.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
diff --git a/dlls/kernel32/tests/file.c b/dlls/kernel32/tests/file.c index d3cd0fbcd9f..f05f7217371 100644 --- a/dlls/kernel32/tests/file.c +++ b/dlls/kernel32/tests/file.c @@ -1633,6 +1633,7 @@ static void test_CreateFileW(void) static const WCHAR prefix[] = {'p','f','x',0}; static const WCHAR bogus[] = { '\', '\', '.', '\', 'B', 'O', 'G', 'U', 'S', 0 }; DWORD ret; + BY_HANDLE_FILE_INFORMATION info;
ret = GetTempPathW(MAX_PATH, temp_path); if (ret == 0 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) @@ -1711,6 +1712,40 @@ static void test_CreateFileW(void) CloseHandle(hFile); ret = RemoveDirectoryW(filename); ok(ret, "DeleteFileW: error %ld\n", GetLastError()); + + /* Test FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_POSIX_SEMANTICS | FILE_ATTRIBUTE_DIRECTORY */ + hFile = CreateFileW(filename, 0, 0, NULL, CREATE_NEW, + FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_DELETE_ON_CLOSE, NULL); + ok(hFile != INVALID_HANDLE_VALUE, "CreateFileW error %lu\n", GetLastError()); + ret = GetFileInformationByHandle(hFile, &info); + ok(ret, "GetFileInformationByHandle error %lu\n", GetLastError()); + ok(!(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY), "created file is a directory\n"); + CloseHandle(hFile); + + hFile = CreateFileW(filename, 0, 0, NULL, CREATE_NEW, + FILE_FLAG_BACKUP_SEMANTICS | FILE_ATTRIBUTE_DIRECTORY | FILE_FLAG_DELETE_ON_CLOSE, NULL); + ok(hFile != INVALID_HANDLE_VALUE, "CreateFileW error %lu\n", GetLastError()); + ret = GetFileInformationByHandle(hFile, &info); + ok(ret, "GetFileInformationByHandle error %lu\n", GetLastError()); + ok(!(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY), "created file is a directory\n"); + CloseHandle(hFile); + + hFile = CreateFileW(filename, 0, 0, NULL, CREATE_NEW, + FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_POSIX_SEMANTICS | FILE_ATTRIBUTE_DIRECTORY | FILE_FLAG_DELETE_ON_CLOSE, NULL); + ok(hFile != INVALID_HANDLE_VALUE, "CreateFileW error %lu\n", GetLastError()); + ret = GetFileInformationByHandle(hFile, &info); + ok(ret, "GetFileInformationByHandle error %lu\n", GetLastError()); + todo_wine + ok(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY, "created file is not a directory\n"); + CloseHandle(hFile); + + hFile = CreateFileW(filename, 0, 0, NULL, CREATE_NEW, + FILE_FLAG_POSIX_SEMANTICS | FILE_ATTRIBUTE_DIRECTORY | FILE_FLAG_DELETE_ON_CLOSE, NULL); + ok(hFile != INVALID_HANDLE_VALUE, "CreateFileW error %lu\n", GetLastError()); + ret = GetFileInformationByHandle(hFile, &info); + ok(ret, "GetFileInformationByHandle error %lu\n", GetLastError()); + ok(!(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY), "created file is a directory\n"); + CloseHandle(hFile); }
static void test_CreateFile2(void)
From: Dmitry Timoshkov dmitry@baikal.ru
According to the tests this behaviour depends on FILE_FLAG_POSIX_SEMANTICS.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58636 Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/kernel32/tests/file.c | 1 - dlls/kernelbase/file.c | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/dlls/kernel32/tests/file.c b/dlls/kernel32/tests/file.c index f05f7217371..b4278425311 100644 --- a/dlls/kernel32/tests/file.c +++ b/dlls/kernel32/tests/file.c @@ -1735,7 +1735,6 @@ static void test_CreateFileW(void) ok(hFile != INVALID_HANDLE_VALUE, "CreateFileW error %lu\n", GetLastError()); ret = GetFileInformationByHandle(hFile, &info); ok(ret, "GetFileInformationByHandle error %lu\n", GetLastError()); - todo_wine ok(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY, "created file is not a directory\n"); CloseHandle(hFile);
diff --git a/dlls/kernelbase/file.c b/dlls/kernelbase/file.c index b34a3bb25b8..6d70b17df21 100644 --- a/dlls/kernelbase/file.c +++ b/dlls/kernelbase/file.c @@ -763,7 +763,11 @@ static UINT get_nt_file_options( DWORD attributes ) UINT options = 0;
if (attributes & FILE_FLAG_BACKUP_SEMANTICS) + { options |= FILE_OPEN_FOR_BACKUP_INTENT; + if (attributes & FILE_FLAG_POSIX_SEMANTICS) + options |= (attributes & FILE_ATTRIBUTE_DIRECTORY) ? FILE_DIRECTORY_FILE : 0; + } else options |= FILE_NON_DIRECTORY_FILE; if (attributes & FILE_FLAG_DELETE_ON_CLOSE)
It would be interesting to also test opening an existing file/directory with these flags.