Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(480)

Side by Side Diff: util/file/file_io_win.cc

Issue 812593005: Add LoggingSeekFile (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: SetFilePointerEx Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « util/file/file_io_posix.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « util/file/file_io_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698