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

Side by Side Diff: base/platform_file_win.cc

Issue 22841004: Negative check for a HANDLE is invalid. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 months 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 | « no previous file | 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 (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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698