update for HEAD-2003091401
[reactos.git] / lib / crtdll / io / access.c
1 #include <windows.h>
2 #include <msvcrt/io.h>
3 #include <msvcrt/errno.h>
4 #define NDEBUG
5 #include <msvcrt/msvcrtdbg.h>
6
7
8 /*
9  * @implemented
10  */
11 int _access( const char *_path, int _amode )
12 {
13     DWORD Attributes = GetFileAttributesA(_path);
14     DPRINT("_access('%s', %x)\n", _path, _amode);
15
16     if (Attributes == -1)   {
17         __set_errno(ENOENT);
18         return -1;
19     }
20     if ((_amode & W_OK) == W_OK) {
21         if ((Attributes & FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY) {
22             __set_errno(EACCES);
23             return -1;
24         }
25     }
26     if ((_amode & D_OK) == D_OK) {
27         if ((Attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) {
28             __set_errno(EACCES);
29             return -1;
30         }
31     }
32     return 0;
33 }