074753d7621ad65116b59114f288e9ec5080b9b9
[reactos.git] / reactos / lib / crtdll / old cruft / io / access.c
1 #include <precomp.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 }