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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 disposition = CREATE_NEW; | 96 disposition = CREATE_NEW; |
97 break; | 97 break; |
98 } | 98 } |
99 HANDLE file = CreateFile(path.value().c_str(), GENERIC_WRITE, 0, nullptr, | 99 HANDLE file = CreateFile(path.value().c_str(), GENERIC_WRITE, 0, nullptr, |
100 disposition, FILE_ATTRIBUTE_NORMAL, nullptr); | 100 disposition, FILE_ATTRIBUTE_NORMAL, nullptr); |
101 PLOG_IF(ERROR, file == INVALID_HANDLE_VALUE) << "CreateFile " | 101 PLOG_IF(ERROR, file == INVALID_HANDLE_VALUE) << "CreateFile " |
102 << path.value().c_str(); | 102 << path.value().c_str(); |
103 return file; | 103 return file; |
104 } | 104 } |
105 | 105 |
| 106 FileOffset LoggingSeekFile(FileHandle file, FileOffset offset, int whence) { |
| 107 DWORD method = 0; |
| 108 switch (whence) { |
| 109 case SEEK_SET: |
| 110 method = FILE_BEGIN; |
| 111 break; |
| 112 case SEEK_CUR: |
| 113 method = FILE_CURRENT; |
| 114 break; |
| 115 case SEEK_END: |
| 116 method = FILE_END; |
| 117 break; |
| 118 default: |
| 119 NOTREACHED(); |
| 120 break; |
| 121 } |
| 122 |
| 123 LARGE_INTEGER distance_to_move; |
| 124 distance_to_move.QuadPart = offset; |
| 125 LARGE_INTEGER new_offset; |
| 126 BOOL result = SetFilePointerEx(file, distance_to_move, &new_offset, method); |
| 127 if (!result) { |
| 128 PLOG(ERROR) << "SetFilePointerEx"; |
| 129 return -1; |
| 130 } |
| 131 return new_offset.QuadPart; |
| 132 } |
| 133 |
106 bool LoggingCloseFile(FileHandle file) { | 134 bool LoggingCloseFile(FileHandle file) { |
107 BOOL rv = CloseHandle(file); | 135 BOOL rv = CloseHandle(file); |
108 PLOG_IF(ERROR, !rv) << "CloseHandle"; | 136 PLOG_IF(ERROR, !rv) << "CloseHandle"; |
109 return rv; | 137 return rv; |
110 } | 138 } |
111 | 139 |
112 } // namespace crashpad | 140 } // namespace crashpad |
OLD | NEW |