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"; |