Alexandre Julliard : ntdll: Use a RunOnce function to initialize directory lookup options.
Alexandre Julliard
julliard at winehq.org
Thu Aug 29 13:18:15 CDT 2013
Module: wine
Branch: master
Commit: d191d5bca01c8e517daf3f7c4019cce09ede62bb
URL: http://source.winehq.org/git/wine.git/?a=commit;h=d191d5bca01c8e517daf3f7c4019cce09ede62bb
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Aug 29 16:48:23 2013 +0200
ntdll: Use a RunOnce function to initialize directory lookup options.
---
dlls/ntdll/directory.c | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c
index cf89879..f65cc9f 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)
More information about the wine-cvs
mailing list