X-Git-Url: http://git.jankratochvil.net/?p=reactos.git;a=blobdiff_plain;f=lib%2Fcrtdll%2Fio%2Faccess.c;h=4babf62c60d8f6385b6e7db0a245fba4d26bf732;hp=47f66cd404c27effe1abcf6e8ce0ebacc316224b;hb=03af8776dc14167b078911b0c7c5327d1bcdd128;hpb=f4077c1bf64ef89d74a8d4822d2d7aada3ba9927 diff --git a/lib/crtdll/io/access.c b/lib/crtdll/io/access.c index 47f66cd..4babf62 100644 --- a/lib/crtdll/io/access.c +++ b/lib/crtdll/io/access.c @@ -1,38 +1,30 @@ -#include #include +#include +#include +#define NDEBUG +#include -#ifndef F_OK - #define F_OK 0x01 -#endif -#ifndef R_OK - #define R_OK 0x02 -#endif -#ifndef W_OK - #define W_OK 0x04 -#endif -#ifndef X_OK - #define X_OK 0x08 -#endif -#ifndef D_OK - #define D_OK 0x10 -#endif int _access( const char *_path, int _amode ) { - DWORD Attributes = GetFileAttributesA(_path); + DWORD Attributes = GetFileAttributesA(_path); + DPRINT("_access('%s', %x)\n", _path, _amode); - if ( Attributes == -1 ) - return -1; - - if ( (_amode & W_OK) == W_OK ) { - if ( (Attributes & FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY ) - return -1; - } - if ( (_amode & D_OK) == D_OK ) { - if ( (Attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY ) - return -1; - } - - return 0; - + if (Attributes == -1) { + __set_errno(ENOENT); + return -1; + } + if ((_amode & W_OK) == W_OK) { + if ((Attributes & FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY) { + __set_errno(EACCES); + return -1; + } + } + if ((_amode & D_OK) == D_OK) { + if ((Attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) { + __set_errno(EACCES); + return -1; + } + } + return 0; }