OLD | NEW |
---|---|
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/file_util.h" | 5 #include "base/file_util.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <propvarutil.h> | 8 #include <propvarutil.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #include <shlobj.h> | 10 #include <shlobj.h> |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
209 // it by now, we don't get better off by deleting the new bits. | 209 // it by now, we don't get better off by deleting the new bits. |
210 } | 210 } |
211 return false; | 211 return false; |
212 } | 212 } |
213 | 213 |
214 | 214 |
215 bool PathExists(const FilePath& path) { | 215 bool PathExists(const FilePath& path) { |
216 return (GetFileAttributes(path.value().c_str()) != INVALID_FILE_ATTRIBUTES); | 216 return (GetFileAttributes(path.value().c_str()) != INVALID_FILE_ATTRIBUTES); |
217 } | 217 } |
218 | 218 |
219 bool PathIsReadable(const FilePath& path) { | |
220 HANDLE dir = | |
221 CreateFile(path.value().c_str(), FILE_READ_DATA, | |
wtc
2010/01/12 19:51:02
I'm surprised that we have to test if a file is re
agl
2010/01/25 14:14:09
Ah, _access looks good. I've switched to using tha
| |
222 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, | |
223 NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); | |
224 | |
225 if (dir == INVALID_HANDLE_VALUE) | |
226 return false; | |
227 | |
228 CloseHandle(dir); | |
229 return true; | |
230 } | |
231 | |
219 bool PathIsWritable(const FilePath& path) { | 232 bool PathIsWritable(const FilePath& path) { |
220 HANDLE dir = | 233 HANDLE dir = |
221 CreateFile(path.value().c_str(), FILE_ADD_FILE, | 234 CreateFile(path.value().c_str(), FILE_ADD_FILE, |
222 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, | 235 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, |
223 NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); | 236 NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); |
224 | 237 |
225 if (dir == INVALID_HANDLE_VALUE) | 238 if (dir == INVALID_HANDLE_VALUE) |
226 return false; | 239 return false; |
227 | 240 |
228 CloseHandle(dir); | 241 CloseHandle(dir); |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
846 } | 859 } |
847 | 860 |
848 bool HasFileBeenModifiedSince(const FileEnumerator::FindInfo& find_info, | 861 bool HasFileBeenModifiedSince(const FileEnumerator::FindInfo& find_info, |
849 const base::Time& cutoff_time) { | 862 const base::Time& cutoff_time) { |
850 long result = CompareFileTime(&find_info.ftLastWriteTime, | 863 long result = CompareFileTime(&find_info.ftLastWriteTime, |
851 &cutoff_time.ToFileTime()); | 864 &cutoff_time.ToFileTime()); |
852 return result == 1 || result == 0; | 865 return result == 1 || result == 0; |
853 } | 866 } |
854 | 867 |
855 } // namespace file_util | 868 } // namespace file_util |
OLD | NEW |