ReactOS 0.4.16-dev-853-g88d9285
wchmod.cpp
Go to the documentation of this file.
1//
2// wchmod.cpp
3//
4// Copyright (c) Microsoft Corporation. All rights reserved.
5//
6// The _wchmod() function, which changes file attributes.
7//
8#include <corecrt_internal.h>
9#include <io.h>
10#include <sys/stat.h>
11
12
13
14// Changes the mode of a file. The only supported mode bit is _S_IWRITE, which
15// controls the user write (read-only) attribute of the file. Returns zero if
16// successful; returns -1 and sets errno and _doserrno on failure.
17extern "C" int __cdecl _wchmod(wchar_t const* const path, int const mode)
18{
20
23 {
25 return -1;
26 }
27
28 // Set or clear the read-only flag:
29 if (mode & _S_IWRITE)
30 {
31 attributes.dwFileAttributes &= ~FILE_ATTRIBUTE_READONLY;
32 }
33 else
34 {
36 }
37
39 {
41 return -1;
42 }
43
44 return 0;
45}
#define EINVAL
Definition: acclib.h:90
#define __cdecl
Definition: accygwin.h:79
void __cdecl __acrt_errno_map_os_error(unsigned long)
Definition: errno.cpp:91
#define _S_IWRITE
Definition: cabinet.h:33
BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:794
BOOL WINAPI GetFileAttributesExW(LPCWSTR lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, LPVOID lpFileInformation)
Definition: fileinfo.c:552
GLenum mode
Definition: glext.h:6217
#define _VALIDATE_CLEAR_OSSERR_RETURN(expr, errorcode, retexpr)
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
int __cdecl _wchmod(wchar_t const *const path, int const mode)
Definition: wchmod.cpp:17
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
@ GetFileExInfoStandard
Definition: winbase.h:1186