Commit 4ad75758 authored by Torge Matthies's avatar Torge Matthies Committed by Alexandre Julliard

ntdll/tests: Add test for file attributes of files with names beginning with a dot.

parent 2b7ba087
......@@ -4051,6 +4051,97 @@ static void test_file_attribute_tag_information(void)
CloseHandle( h );
}
static void rename_file( HANDLE h, const WCHAR *filename )
{
FILE_RENAME_INFORMATION *fri;
UNICODE_STRING ntpath;
IO_STATUS_BLOCK io;
NTSTATUS status;
BOOLEAN ret;
ULONG size;
ret = pRtlDosPathNameToNtPathName_U( filename, &ntpath, NULL, NULL );
ok( ret, "RtlDosPathNameToNtPathName_U failed\n" );
size = offsetof( FILE_RENAME_INFORMATION, FileName ) + ntpath.Length;
fri = HeapAlloc( GetProcessHeap(), 0, size );
ok( fri != NULL, "HeapAlloc failed\n" );
fri->ReplaceIfExists = TRUE;
fri->RootDirectory = NULL;
fri->FileNameLength = ntpath.Length;
memcpy( fri->FileName, ntpath.Buffer, ntpath.Length );
pRtlFreeUnicodeString( &ntpath );
status = pNtSetInformationFile( h, &io, fri, size, FileRenameInformation );
HeapFree( GetProcessHeap(), 0, fri );
ok( status == STATUS_SUCCESS, "got %#lx\n", status );
}
static void test_dotfile_file_attributes(void)
{
char temppath[MAX_PATH], filename[MAX_PATH];
WCHAR temppathW[MAX_PATH], filenameW[MAX_PATH];
FILE_BASIC_INFORMATION info = {};
IO_STATUS_BLOCK io;
NTSTATUS status;
DWORD attrs;
HANDLE h;
GetTempPathA( MAX_PATH, temppath );
GetTempFileNameA( temppath, ".foo", 0, filename );
h = CreateFileA( filename, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, 0 );
ok( h != INVALID_HANDLE_VALUE, "failed to create temp file\n" );
status = nt_get_file_attrs(filename, &attrs);
ok( status == STATUS_SUCCESS, "got %#lx\n", status );
todo_wine ok( !(attrs & FILE_ATTRIBUTE_HIDDEN), "got attributes %#lx\n", attrs );
status = pNtQueryInformationFile( h, &io, &info, sizeof(info), FileBasicInformation );
ok( status == STATUS_SUCCESS, "got %#lx\n", status );
ok( !(info.FileAttributes & FILE_ATTRIBUTE_HIDDEN), "got attributes %#lx\n", info.FileAttributes );
info.FileAttributes = FILE_ATTRIBUTE_SYSTEM;
status = pNtSetInformationFile( h, &io, &info, sizeof(info), FileBasicInformation );
ok( status == STATUS_SUCCESS, "got %#lx\n", status );
status = nt_get_file_attrs(filename, &attrs);
ok( status == STATUS_SUCCESS, "got %#lx\n", status );
ok( attrs & FILE_ATTRIBUTE_SYSTEM, "got attributes %#lx\n", attrs );
todo_wine ok( !(attrs & FILE_ATTRIBUTE_HIDDEN), "got attributes %#lx\n", attrs );
status = pNtQueryInformationFile( h, &io, &info, sizeof(info), FileBasicInformation );
ok( status == STATUS_SUCCESS, "got %#lx\n", status );
ok( info.FileAttributes & FILE_ATTRIBUTE_SYSTEM, "got attributes %#lx\n", info.FileAttributes );
ok( !(info.FileAttributes & FILE_ATTRIBUTE_HIDDEN), "got attributes %#lx\n", info.FileAttributes );
CloseHandle( h );
GetTempPathW( MAX_PATH, temppathW );
GetTempFileNameW( temppathW, L"foo", 0, filenameW );
h = CreateFileW( filenameW, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, 0 );
ok( h != INVALID_HANDLE_VALUE, "failed to create temp file\n" );
GetTempFileNameW( temppathW, L".foo", 0, filenameW );
winetest_push_context("foo -> .foo");
rename_file( h, filenameW );
winetest_pop_context();
status = pNtQueryInformationFile( h, &io, &info, sizeof(info), FileBasicInformation );
ok( status == STATUS_SUCCESS, "got %#lx\n", status );
ok( !(info.FileAttributes & FILE_ATTRIBUTE_HIDDEN), "got attributes %#lx\n", info.FileAttributes );
GetTempFileNameW( temppathW, L"foo", 0, filenameW );
winetest_push_context(".foo -> foo");
rename_file( h, filenameW );
winetest_pop_context();
status = pNtQueryInformationFile( h, &io, &info, sizeof(info), FileBasicInformation );
ok( status == STATUS_SUCCESS, "got %#lx\n", status );
ok( !(info.FileAttributes & FILE_ATTRIBUTE_HIDDEN), "got attributes %#lx\n", info.FileAttributes );
CloseHandle( h );
}
static void test_file_mode(void)
{
UNICODE_STRING file_name, pipe_dev_name, mountmgr_dev_name, mailslot_dev_name;
......@@ -5499,6 +5590,7 @@ START_TEST(file)
test_file_id_information();
test_file_access_information();
test_file_attribute_tag_information();
test_dotfile_file_attributes();
test_file_mode();
test_file_readonly_access();
test_query_volume_information_file();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment