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

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: . 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 CHECK(whence == SEEK_SET || whence == SEEK_CUR || whence == SEEK_END);
Mark Mentovai 2014/12/19 14:51:00 I think this one would be OK as a DCHECK. It’s kin
scottmg 2014/12/19 17:57:23 Done.
108
109 DWORD method = 0;
110 switch (whence) {
111 case SEEK_SET:
Mark Mentovai 2014/12/19 14:51:00 CL description: “both” → “bother”.
scottmg 2014/12/19 17:57:23 Done.
112 method = FILE_BEGIN;
113 break;
114 case SEEK_CUR:
115 method = FILE_CURRENT;
116 break;
117 case SEEK_END:
118 method = FILE_END;
119 break;
120 }
121
122 LARGE_INTEGER li;
123 li.QuadPart = offset;
124 li.LowPart = SetFilePointer(file, li.LowPart, &li.HighPart, method);
Mark Mentovai 2014/12/19 14:51:00 Wow, this is a really weird function! I had to che
scottmg 2014/12/19 17:57:23 Ah, for some reason I thought Ex was Vista+. Switc
125 if (li.LowPart == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR) {
126 PLOG(ERROR) << "SetFilePointer";
127 return -1;
128 }
129
130 return li.QuadPart;
131 }
132
106 bool LoggingCloseFile(FileHandle file) { 133 bool LoggingCloseFile(FileHandle file) {
107 BOOL rv = CloseHandle(file); 134 BOOL rv = CloseHandle(file);
108 PLOG_IF(ERROR, !rv) << "CloseHandle"; 135 PLOG_IF(ERROR, !rv) << "CloseHandle";
109 return rv; 136 return rv;
110 } 137 }
111 138
112 } // namespace crashpad 139 } // 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