Stub implementation for ReadDirectoryChangesW.
[wine] / dlls / kernel / change.c
1 /*
2  * Win32 file change notification functions
3  *
4  * Copyright 1998 Ulrich Weigand
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "config.h"
22
23 #include <stdarg.h>
24 #include <stdlib.h>
25 #include <string.h>
26
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winerror.h"
30 #include "ntstatus.h"
31 #include "kernel_private.h"
32 #include "wine/windef16.h"
33 #include "wine/server.h"
34 #include "wine/debug.h"
35
36 WINE_DEFAULT_DEBUG_CHANNEL(file);
37
38 /****************************************************************************
39  *              FindFirstChangeNotificationA (KERNEL32.@)
40  */
41 HANDLE WINAPI FindFirstChangeNotificationA( LPCSTR lpPathName, BOOL bWatchSubtree,
42                                             DWORD dwNotifyFilter )
43 {
44     WCHAR *pathW;
45
46     if (!(pathW = FILE_name_AtoW( lpPathName, FALSE ))) return INVALID_HANDLE_VALUE;
47     return FindFirstChangeNotificationW( pathW, bWatchSubtree, dwNotifyFilter );
48 }
49
50 /****************************************************************************
51  *              FindFirstChangeNotificationW (KERNEL32.@)
52  */
53 HANDLE WINAPI FindFirstChangeNotificationW( LPCWSTR lpPathName, BOOL bWatchSubtree,
54                                             DWORD dwNotifyFilter)
55 {
56     UNICODE_STRING nt_name;
57     OBJECT_ATTRIBUTES attr;
58     IO_STATUS_BLOCK io;
59     NTSTATUS status;
60     HANDLE file, ret = INVALID_HANDLE_VALUE;
61
62     TRACE( "%s %d %lx\n", debugstr_w(lpPathName), bWatchSubtree, dwNotifyFilter );
63
64     if (!RtlDosPathNameToNtPathName_U( lpPathName, &nt_name, NULL, NULL ))
65     {
66         SetLastError( ERROR_PATH_NOT_FOUND );
67         return INVALID_HANDLE_VALUE;
68     }
69
70     attr.Length = sizeof(attr);
71     attr.RootDirectory = 0;
72     attr.Attributes = OBJ_CASE_INSENSITIVE;
73     attr.ObjectName = &nt_name;
74     attr.SecurityDescriptor = NULL;
75     attr.SecurityQualityOfService = NULL;
76
77     status = NtOpenFile( &file, 0, &attr, &io, 0,
78                          FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT );
79     RtlFreeUnicodeString( &nt_name );
80
81     if (status != STATUS_SUCCESS)
82     {
83         SetLastError( RtlNtStatusToDosError(status) );
84         return INVALID_HANDLE_VALUE;
85     }
86
87     SERVER_START_REQ( create_change_notification )
88     {
89         req->handle  = file;
90         req->subtree = bWatchSubtree;
91         req->filter  = dwNotifyFilter;
92         if (!wine_server_call_err( req )) ret = reply->handle;
93     }
94     SERVER_END_REQ;
95     CloseHandle( file );
96     return ret;
97 }
98
99 /****************************************************************************
100  *              FindNextChangeNotification (KERNEL32.@)
101  */
102 BOOL WINAPI FindNextChangeNotification( HANDLE handle )
103 {
104     BOOL ret;
105
106     TRACE("%p\n",handle);
107
108     SERVER_START_REQ( next_change_notification )
109     {
110         req->handle = handle;
111         ret = !wine_server_call_err( req );
112     }
113     SERVER_END_REQ;
114     return ret;
115 }
116
117 /****************************************************************************
118  *              FindCloseChangeNotification (KERNEL32.@)
119  */
120 BOOL WINAPI FindCloseChangeNotification( HANDLE handle )
121 {
122     return CloseHandle( handle );
123 }
124
125 /***********************************************************************
126 *       FileCDR (KERNEL.130)
127 */
128 FARPROC16 WINAPI FileCDR16(FARPROC16 x)
129 {
130     FIXME("(0x%8x): stub\n", (int) x);
131     return (FARPROC16)TRUE;
132 }
133
134 BOOL WINAPI ReadDirectoryChangesW( HANDLE handle, LPVOID buffer, DWORD len, BOOL subtree,
135                                    DWORD filter, LPDWORD returned, LPOVERLAPPED overlapped,
136                                    LPOVERLAPPED_COMPLETION_ROUTINE completion )
137 {
138     FIXME( "%p %p 0x%08lx %d 0x%08lx %p %p %p\n", handle, buffer, len, subtree, filter,
139            returned, overlapped, completion );
140
141     SetLastError( ERROR_INVALID_FUNCTION );
142     return FALSE;
143 }