OLD | NEW |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 case FileWriteMode::kReuseOrCreate: | 95 case FileWriteMode::kReuseOrCreate: |
96 disposition = OPEN_ALWAYS; | 96 disposition = OPEN_ALWAYS; |
97 break; | 97 break; |
98 case FileWriteMode::kTruncateOrCreate: | 98 case FileWriteMode::kTruncateOrCreate: |
99 disposition = CREATE_ALWAYS; | 99 disposition = CREATE_ALWAYS; |
100 break; | 100 break; |
101 case FileWriteMode::kCreateOrFail: | 101 case FileWriteMode::kCreateOrFail: |
102 disposition = CREATE_NEW; | 102 disposition = CREATE_NEW; |
103 break; | 103 break; |
104 } | 104 } |
105 HANDLE file = CreateFile(path.value().c_str(), GENERIC_WRITE, 0, nullptr, | 105 HANDLE file = CreateFile(path.value().c_str(), |
106 disposition, FILE_ATTRIBUTE_NORMAL, nullptr); | 106 GENERIC_READ | GENERIC_WRITE, |
| 107 0, |
| 108 nullptr, |
| 109 disposition, |
| 110 FILE_ATTRIBUTE_NORMAL, |
| 111 nullptr); |
107 PLOG_IF(ERROR, file == INVALID_HANDLE_VALUE) << "CreateFile " | 112 PLOG_IF(ERROR, file == INVALID_HANDLE_VALUE) << "CreateFile " |
108 << path.value().c_str(); | 113 << path.value().c_str(); |
109 return file; | 114 return file; |
110 } | 115 } |
111 | 116 |
112 FileOffset LoggingSeekFile(FileHandle file, FileOffset offset, int whence) { | 117 FileOffset LoggingSeekFile(FileHandle file, FileOffset offset, int whence) { |
113 DWORD method = 0; | 118 DWORD method = 0; |
114 switch (whence) { | 119 switch (whence) { |
115 case SEEK_SET: | 120 case SEEK_SET: |
116 method = FILE_BEGIN; | 121 method = FILE_BEGIN; |
(...skipping 20 matching lines...) Expand all Loading... |
137 return new_offset.QuadPart; | 142 return new_offset.QuadPart; |
138 } | 143 } |
139 | 144 |
140 bool LoggingCloseFile(FileHandle file) { | 145 bool LoggingCloseFile(FileHandle file) { |
141 BOOL rv = CloseHandle(file); | 146 BOOL rv = CloseHandle(file); |
142 PLOG_IF(ERROR, !rv) << "CloseHandle"; | 147 PLOG_IF(ERROR, !rv) << "CloseHandle"; |
143 return rv; | 148 return rv; |
144 } | 149 } |
145 | 150 |
146 } // namespace crashpad | 151 } // namespace crashpad |
OLD | NEW |