diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c index cf898798b49..f65cc9f8a39 100644 --- a/dlls/ntdll/directory.c +++ b/dlls/ntdll/directory.c @@ -157,7 +157,8 @@ union file_directory_info FILE_ID_FULL_DIRECTORY_INFORMATION id_full; }; -static int show_dot_files = -1; +static BOOL show_dot_files; +static RTL_RUN_ONCE init_once = RTL_RUN_ONCE_INIT; /* at some point we may want to allow Winelib apps to set this */ static const int is_case_sensitive = FALSE; @@ -1036,7 +1037,7 @@ static BOOLEAN get_dir_case_sensitivity( const char *dir ) * * Initialize the show_dot_files options. */ -static void init_options(void) +static DWORD WINAPI init_options( RTL_RUN_ONCE *once, void *param, void **context ) { static const WCHAR WineW[] = {'S','o','f','t','w','a','r','e','\\','W','i','n','e',0}; static const WCHAR ShowDotFilesW[] = {'S','h','o','w','D','o','t','F','i','l','e','s',0}; @@ -1046,8 +1047,6 @@ static void init_options(void) OBJECT_ATTRIBUTES attr; UNICODE_STRING nameW; - show_dot_files = 0; - RtlOpenCurrentUser( KEY_ALL_ACCESS, &root ); attr.Length = sizeof(attr); attr.RootDirectory = root; @@ -1077,6 +1076,7 @@ static void init_options(void) #ifdef linux ignore_file( "/sys" ); #endif + return TRUE; } @@ -1089,7 +1089,8 @@ BOOL DIR_is_hidden_file( const UNICODE_STRING *name ) { WCHAR *p, *end; - if (show_dot_files == -1) init_options(); + RtlRunOnceExecuteOnce( &init_once, init_options, NULL, NULL ); + if (show_dot_files) return FALSE; end = p = name->Buffer + name->Length/sizeof(WCHAR); @@ -2053,9 +2054,9 @@ NTSTATUS WINAPI NtQueryDirectoryFile( HANDLE handle, HANDLE event, io->Information = 0; - RtlEnterCriticalSection( &dir_section ); + RtlRunOnceExecuteOnce( &init_once, init_options, NULL, NULL ); - if (show_dot_files == -1) init_options(); + RtlEnterCriticalSection( &dir_section ); cwd = open( ".", O_RDONLY ); if (fchdir( fd ) != -1)