OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/platform_file.h" | 5 #include "base/platform_file.h" |
6 | 6 |
7 #include <io.h> | 7 #include <io.h> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 114 |
115 bool ClosePlatformFile(PlatformFile file) { | 115 bool ClosePlatformFile(PlatformFile file) { |
116 base::ThreadRestrictions::AssertIOAllowed(); | 116 base::ThreadRestrictions::AssertIOAllowed(); |
117 return (CloseHandle(file) != 0); | 117 return (CloseHandle(file) != 0); |
118 } | 118 } |
119 | 119 |
120 int64 SeekPlatformFile(PlatformFile file, | 120 int64 SeekPlatformFile(PlatformFile file, |
121 PlatformFileWhence whence, | 121 PlatformFileWhence whence, |
122 int64 offset) { | 122 int64 offset) { |
123 base::ThreadRestrictions::AssertIOAllowed(); | 123 base::ThreadRestrictions::AssertIOAllowed(); |
124 if (file < 0 || offset < 0) | 124 if (file == kInvalidPlatformFileValue || offset < 0) |
125 return -1; | 125 return -1; |
126 | 126 |
127 LARGE_INTEGER distance, res; | 127 LARGE_INTEGER distance, res; |
128 distance.QuadPart = offset; | 128 distance.QuadPart = offset; |
129 DWORD move_method = static_cast<DWORD>(whence); | 129 DWORD move_method = static_cast<DWORD>(whence); |
130 if (!SetFilePointerEx(file, distance, &res, move_method)) | 130 if (!SetFilePointerEx(file, distance, &res, move_method)) |
131 return -1; | 131 return -1; |
132 return res.QuadPart; | 132 return res.QuadPart; |
133 } | 133 } |
134 | 134 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 case ERROR_DISK_CORRUPT: | 292 case ERROR_DISK_CORRUPT: |
293 return PLATFORM_FILE_ERROR_IO; | 293 return PLATFORM_FILE_ERROR_IO; |
294 default: | 294 default: |
295 UMA_HISTOGRAM_SPARSE_SLOWLY("PlatformFile.UnknownErrors.Windows", | 295 UMA_HISTOGRAM_SPARSE_SLOWLY("PlatformFile.UnknownErrors.Windows", |
296 last_error); | 296 last_error); |
297 return PLATFORM_FILE_ERROR_FAILED; | 297 return PLATFORM_FILE_ERROR_FAILED; |
298 } | 298 } |
299 } | 299 } |
300 | 300 |
301 } // namespace base | 301 } // namespace base |
OLD | NEW |