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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « util/file/file_io_posix.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: util/file/file_io_win.cc
diff --git a/util/file/file_io_win.cc b/util/file/file_io_win.cc
index 7426737dcfe9cdaf82e5601ccd1e5f9d97af67d8..dbead0d9bd5e6ef9b39003e16cf3804647eb1d10 100644
--- a/util/file/file_io_win.cc
+++ b/util/file/file_io_win.cc
@@ -103,6 +103,33 @@ FileHandle LoggingOpenFileForWrite(const base::FilePath& path,
return file;
}
+FileOffset LoggingSeekFile(FileHandle file, FileOffset offset, int whence) {
+ 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.
+
+ DWORD method = 0;
+ switch (whence) {
+ case SEEK_SET:
Mark Mentovai 2014/12/19 14:51:00 CL description: “both” → “bother”.
scottmg 2014/12/19 17:57:23 Done.
+ method = FILE_BEGIN;
+ break;
+ case SEEK_CUR:
+ method = FILE_CURRENT;
+ break;
+ case SEEK_END:
+ method = FILE_END;
+ break;
+ }
+
+ LARGE_INTEGER li;
+ li.QuadPart = offset;
+ 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
+ if (li.LowPart == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR) {
+ PLOG(ERROR) << "SetFilePointer";
+ return -1;
+ }
+
+ return li.QuadPart;
+}
+
bool LoggingCloseFile(FileHandle file) {
BOOL rv = CloseHandle(file);
PLOG_IF(ERROR, !rv) << "CloseHandle";
« 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