ReactOS 0.4.16-dev-959-g2ec3a19
waccess.cpp File Reference
#include <corecrt_internal.h>
#include <io.h>
Include dependency graph for waccess.cpp:

Go to the source code of this file.

Functions

errno_t __cdecl _waccess_s (wchar_t const *const path, int const access_mode)
 
int __cdecl _waccess (wchar_t const *const path, int const access_mode)
 

Function Documentation

◆ _waccess()

int __cdecl _waccess ( wchar_t const *const  path,
int const  access_mode 
)

Definition at line 52 of file waccess.cpp.

53{
54 return _waccess_s(path, access_mode) == 0 ? 0 : -1;
55}
errno_t __cdecl _waccess_s(wchar_t const *const path, int const access_mode)
Definition: waccess.cpp:17

◆ _waccess_s()

errno_t __cdecl _waccess_s ( wchar_t const *const  path,
int const  access_mode 
)

Definition at line 17 of file waccess.cpp.

18{
20 _VALIDATE_CLEAR_OSSERR_RETURN_ERRCODE((access_mode & (~6)) == 0, EINVAL);
21
24 {
26 return errno;
27 }
28
29 // All directories have both read and write access:
31 return 0;
32
33 // If we require write access, make sure the read only flag is not set:
34 bool const file_is_read_only = (attributes.dwFileAttributes & FILE_ATTRIBUTE_READONLY) != 0;
35 bool const mode_requires_write = (access_mode & 2) != 0;
36
37 if (file_is_read_only && mode_requires_write)
38 {
40 errno = EACCES;
41 return errno;
42 }
43
44 // Otherwise, the file is accessible:
45 return 0;
46
47}
#define EINVAL
Definition: acclib.h:90
#define EACCES
Definition: acclib.h:85
void __cdecl __acrt_errno_map_os_error(unsigned long)
Definition: errno.cpp:91
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
BOOL WINAPI GetFileAttributesExW(LPCWSTR lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, LPVOID lpFileInformation)
Definition: fileinfo.c:552
#define _doserrno
Definition: stdlib.h:131
#define _VALIDATE_CLEAR_OSSERR_RETURN_ERRCODE(expr, errorcode)
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define errno
Definition: errno.h:18
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
@ GetFileExInfoStandard
Definition: winbase.h:1192

Referenced by _waccess().