proxygen
SysStat.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2016-present Facebook, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 #ifdef _WIN32
21 
22 extern "C" {
23 int chmod(char const* fn, int am) {
24  return _chmod(fn, am);
25 }
26 
27 int fchmod(int fd, mode_t mode) {
28  HANDLE h = (HANDLE)_get_osfhandle(fd);
29  if (h == INVALID_HANDLE_VALUE) {
30  return -1;
31  }
32 
33  FILE_ATTRIBUTE_TAG_INFO attr{};
34  if (!GetFileInformationByHandleEx(
35  h, FileAttributeTagInfo, &attr, sizeof(attr))) {
36  return -1;
37  }
38 
39  if (mode & _S_IWRITE) {
40  attr.FileAttributes &= ~FILE_ATTRIBUTE_READONLY;
41  } else {
42  attr.FileAttributes |= FILE_ATTRIBUTE_READONLY;
43  }
44 
45  if (!SetFileInformationByHandle(
46  h, FileAttributeTagInfo, &attr, sizeof(attr))) {
47  return -1;
48  }
49 
50  return 0;
51 }
52 
53 // Just return the result of a normal stat for now
54 int lstat(const char* path, struct stat* st) {
55  return stat(path, st);
56 }
57 
58 int mkdir(const char* fn, int /* mode */) {
59  return _mkdir(fn);
60 }
61 
62 int umask(int md) {
63  return _umask(md);
64 }
65 }
66 #endif
*than *hazptr_holder h
Definition: Hazptr.h:116
folly::Optional< PskKeyExchangeMode > mode