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

Side by Side Diff: base/files/file_util_win.cc

Issue 1350493002: Check for CloseHandle failures even when not debugging (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DCHECK to CHECK Created 5 years, 3 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 | base/memory/shared_memory_win.cc » ('j') | base/memory/shared_memory_win.cc » ('J')
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/files/file_util.h" 5 #include "base/files/file_util.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <io.h> 8 #include <io.h>
9 #include <psapi.h> 9 #include <psapi.h>
10 #include <shellapi.h> 10 #include <shellapi.h>
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 return success; 224 return success;
225 } 225 }
226 226
227 bool PathExists(const FilePath& path) { 227 bool PathExists(const FilePath& path) {
228 ThreadRestrictions::AssertIOAllowed(); 228 ThreadRestrictions::AssertIOAllowed();
229 return (GetFileAttributes(path.value().c_str()) != INVALID_FILE_ATTRIBUTES); 229 return (GetFileAttributes(path.value().c_str()) != INVALID_FILE_ATTRIBUTES);
230 } 230 }
231 231
232 bool PathIsWritable(const FilePath& path) { 232 bool PathIsWritable(const FilePath& path) {
233 ThreadRestrictions::AssertIOAllowed(); 233 ThreadRestrictions::AssertIOAllowed();
234 HANDLE dir = 234 win::ScopedHandle dir(
235 CreateFile(path.value().c_str(), FILE_ADD_FILE, kFileShareAll, 235 CreateFile(path.value().c_str(), FILE_ADD_FILE, kFileShareAll,
236 NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); 236 NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL));
237 237
238 if (dir == INVALID_HANDLE_VALUE) 238 return dir.IsValid();
239 return false;
240
241 CloseHandle(dir);
242 return true;
243 } 239 }
244 240
245 bool DirectoryExists(const FilePath& path) { 241 bool DirectoryExists(const FilePath& path) {
246 ThreadRestrictions::AssertIOAllowed(); 242 ThreadRestrictions::AssertIOAllowed();
247 DWORD fileattr = GetFileAttributes(path.value().c_str()); 243 DWORD fileattr = GetFileAttributes(path.value().c_str());
248 if (fileattr != INVALID_FILE_ATTRIBUTES) 244 if (fileattr != INVALID_FILE_ATTRIBUTES)
249 return (fileattr & FILE_ATTRIBUTE_DIRECTORY) != 0; 245 return (fileattr & FILE_ATTRIBUTE_DIRECTORY) != 0;
250 return false; 246 return false;
251 } 247 }
252 248
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 // Like Move, this function is not transactional, so we just 797 // Like Move, this function is not transactional, so we just
802 // leave the copied bits behind if deleting from_path fails. 798 // leave the copied bits behind if deleting from_path fails.
803 // If to_path exists previously then we have already overwritten 799 // If to_path exists previously then we have already overwritten
804 // it by now, we don't get better off by deleting the new bits. 800 // it by now, we don't get better off by deleting the new bits.
805 } 801 }
806 return false; 802 return false;
807 } 803 }
808 804
809 } // namespace internal 805 } // namespace internal
810 } // namespace base 806 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/memory/shared_memory_win.cc » ('j') | base/memory/shared_memory_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698