Added hack to fetch the current directory from the subsystem tid so
[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 "wine/windef16.h"
31 #include "wine/server.h"
32 #include "wine/debug.h"
33
34 WINE_DEFAULT_DEBUG_CHANNEL(file);
35
36 /****************************************************************************
37  *              FindFirstChangeNotificationA (KERNEL32.@)
38  */
39 HANDLE WINAPI FindFirstChangeNotificationA( LPCSTR lpPathName, BOOL bWatchSubtree,
40                                             DWORD dwNotifyFilter )
41 {
42     HANDLE file, ret = INVALID_HANDLE_VALUE;
43
44     TRACE( "%s %d %lx\n", debugstr_a(lpPathName), bWatchSubtree, dwNotifyFilter );
45
46     if ((file = CreateFileA( lpPathName, 0, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
47                              OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0 )) == INVALID_HANDLE_VALUE)
48         return INVALID_HANDLE_VALUE;
49
50     SERVER_START_REQ( create_change_notification )
51     {
52         req->handle  = file;
53         req->subtree = bWatchSubtree;
54         req->filter  = dwNotifyFilter;
55         if (!wine_server_call_err( req )) ret = reply->handle;
56     }
57     SERVER_END_REQ;
58     CloseHandle( file );
59     return ret;
60 }
61
62 /****************************************************************************
63  *              FindFirstChangeNotificationW (KERNEL32.@)
64  */
65 HANDLE WINAPI FindFirstChangeNotificationW( LPCWSTR lpPathName, BOOL bWatchSubtree,
66                                             DWORD dwNotifyFilter)
67 {
68     HANDLE file, ret = INVALID_HANDLE_VALUE;
69
70     TRACE( "%s %d %lx\n", debugstr_w(lpPathName), bWatchSubtree, dwNotifyFilter );
71
72     if ((file = CreateFileW( lpPathName, 0, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
73                              OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0 )) == INVALID_HANDLE_VALUE)
74         return INVALID_HANDLE_VALUE;
75
76     SERVER_START_REQ( create_change_notification )
77     {
78         req->handle  = file;
79         req->subtree = bWatchSubtree;
80         req->filter  = dwNotifyFilter;
81         if (!wine_server_call_err( req )) ret = reply->handle;
82     }
83     SERVER_END_REQ;
84     CloseHandle( file );
85     return ret;
86 }
87
88 /****************************************************************************
89  *              FindNextChangeNotification (KERNEL32.@)
90  */
91 BOOL WINAPI FindNextChangeNotification( HANDLE handle )
92 {
93     BOOL ret;
94
95     TRACE("%p\n",handle);
96
97     SERVER_START_REQ( next_change_notification )
98     {
99         req->handle = handle;
100         ret = !wine_server_call_err( req );
101     }
102     SERVER_END_REQ;
103     return ret;
104 }
105
106 /****************************************************************************
107  *              FindCloseChangeNotification (KERNEL32.@)
108  */
109 BOOL WINAPI FindCloseChangeNotification( HANDLE handle )
110 {
111     return CloseHandle( handle );
112 }
113
114 /***********************************************************************
115 *       FileCDR (KERNEL.130)
116 */
117 FARPROC16 WINAPI FileCDR16(FARPROC16 x)
118 {
119     FIXME("(0x%8x): stub\n", (int) x);
120     return (FARPROC16)TRUE;
121 }