msvcrt: Use fpclass constants from public header.
[wine/zf.git] / dlls / ntdll / directory.c
blob39641e9d4d5b9fb55595286329b8909ed845a30b
1 /*
2 * NTDLL directory functions
4 * Copyright 1993 Erik Bos
5 * Copyright 2003 Eric Pouech
6 * Copyright 1996, 2004 Alexandre Julliard
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include <assert.h>
24 #include <sys/types.h>
25 #include <fcntl.h>
26 #include <stdarg.h>
27 #include <string.h>
28 #include <stdlib.h>
29 #include <stdio.h>
31 #include "ntstatus.h"
32 #define WIN32_NO_STATUS
33 #define NONAMELESSUNION
34 #include "windef.h"
35 #include "winnt.h"
36 #include "winternl.h"
37 #include "ddk/wdm.h"
38 #include "ntdll_misc.h"
39 #include "wine/server.h"
40 #include "wine/list.h"
41 #include "wine/debug.h"
42 #include "wine/exception.h"
44 #define IS_OPTION_TRUE(ch) ((ch) == 'y' || (ch) == 'Y' || (ch) == 't' || (ch) == 'T' || (ch) == '1')
46 static BOOL show_dot_files;
48 /***********************************************************************
49 * init_directories
51 void init_directories(void)
53 static const WCHAR WineW[] = {'S','o','f','t','w','a','r','e','\\','W','i','n','e',0};
54 static const WCHAR ShowDotFilesW[] = {'S','h','o','w','D','o','t','F','i','l','e','s',0};
55 char tmp[80];
56 HANDLE root, hkey;
57 DWORD dummy;
58 OBJECT_ATTRIBUTES attr;
59 UNICODE_STRING nameW;
61 RtlOpenCurrentUser( KEY_ALL_ACCESS, &root );
62 attr.Length = sizeof(attr);
63 attr.RootDirectory = root;
64 attr.ObjectName = &nameW;
65 attr.Attributes = 0;
66 attr.SecurityDescriptor = NULL;
67 attr.SecurityQualityOfService = NULL;
68 RtlInitUnicodeString( &nameW, WineW );
70 /* @@ Wine registry key: HKCU\Software\Wine */
71 if (!NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ))
73 RtlInitUnicodeString( &nameW, ShowDotFilesW );
74 if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
76 WCHAR *str = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
77 show_dot_files = IS_OPTION_TRUE( str[0] );
79 NtClose( hkey );
81 NtClose( root );
82 unix_funcs->set_show_dot_files( show_dot_files );
86 /******************************************************************
87 * RtlWow64EnableFsRedirection (NTDLL.@)
89 NTSTATUS WINAPI RtlWow64EnableFsRedirection( BOOLEAN enable )
91 #ifdef _WIN64
92 return STATUS_NOT_IMPLEMENTED;
93 #else
94 if (!NtCurrentTeb64()) return STATUS_NOT_IMPLEMENTED;
95 NtCurrentTeb64()->TlsSlots[WOW64_TLS_FILESYSREDIR] = !enable;
96 return STATUS_SUCCESS;
97 #endif
101 /******************************************************************
102 * RtlWow64EnableFsRedirectionEx (NTDLL.@)
104 NTSTATUS WINAPI RtlWow64EnableFsRedirectionEx( ULONG disable, ULONG *old_value )
106 #ifdef _WIN64
107 return STATUS_NOT_IMPLEMENTED;
108 #else
109 if (!NtCurrentTeb64()) return STATUS_NOT_IMPLEMENTED;
111 __TRY
113 *old_value = NtCurrentTeb64()->TlsSlots[WOW64_TLS_FILESYSREDIR];
115 __EXCEPT_PAGE_FAULT
117 return STATUS_ACCESS_VIOLATION;
119 __ENDTRY
121 NtCurrentTeb64()->TlsSlots[WOW64_TLS_FILESYSREDIR] = disable;
122 return STATUS_SUCCESS;
123 #endif
127 /******************************************************************
128 * RtlDoesFileExists_U (NTDLL.@)
130 BOOLEAN WINAPI RtlDoesFileExists_U(LPCWSTR file_name)
132 UNICODE_STRING nt_name;
133 FILE_BASIC_INFORMATION basic_info;
134 OBJECT_ATTRIBUTES attr;
135 BOOLEAN ret;
137 if (!RtlDosPathNameToNtPathName_U( file_name, &nt_name, NULL, NULL )) return FALSE;
139 attr.Length = sizeof(attr);
140 attr.RootDirectory = 0;
141 attr.ObjectName = &nt_name;
142 attr.Attributes = OBJ_CASE_INSENSITIVE;
143 attr.SecurityDescriptor = NULL;
144 attr.SecurityQualityOfService = NULL;
146 ret = NtQueryAttributesFile(&attr, &basic_info) == STATUS_SUCCESS;
148 RtlFreeUnicodeString( &nt_name );
149 return ret;