| 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/file_util.h" | 5 #include "base/file_util.h" |
| 6 | 6 |
| 7 #include <dirent.h> | 7 #include <dirent.h> |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <fcntl.h> | 9 #include <fcntl.h> |
| 10 #include <fnmatch.h> | 10 #include <fnmatch.h> |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 } | 389 } |
| 390 | 390 |
| 391 bool DirectoryExists(const FilePath& path) { | 391 bool DirectoryExists(const FilePath& path) { |
| 392 base::ThreadRestrictions::AssertIOAllowed(); | 392 base::ThreadRestrictions::AssertIOAllowed(); |
| 393 stat_wrapper_t file_info; | 393 stat_wrapper_t file_info; |
| 394 if (CallStat(path.value().c_str(), &file_info) == 0) | 394 if (CallStat(path.value().c_str(), &file_info) == 0) |
| 395 return S_ISDIR(file_info.st_mode); | 395 return S_ISDIR(file_info.st_mode); |
| 396 return false; | 396 return false; |
| 397 } | 397 } |
| 398 | 398 |
| 399 // TODO(erikkay): implement | |
| 400 #if 0 | |
| 401 bool GetFileCreationLocalTimeFromHandle(int fd, | |
| 402 LPSYSTEMTIME creation_time) { | |
| 403 if (!file_handle) | |
| 404 return false; | |
| 405 | |
| 406 FILETIME utc_filetime; | |
| 407 if (!GetFileTime(file_handle, &utc_filetime, NULL, NULL)) | |
| 408 return false; | |
| 409 | |
| 410 FILETIME local_filetime; | |
| 411 if (!FileTimeToLocalFileTime(&utc_filetime, &local_filetime)) | |
| 412 return false; | |
| 413 | |
| 414 return !!FileTimeToSystemTime(&local_filetime, creation_time); | |
| 415 } | |
| 416 | |
| 417 bool GetFileCreationLocalTime(const std::string& filename, | |
| 418 LPSYSTEMTIME creation_time) { | |
| 419 ScopedHandle file_handle( | |
| 420 CreateFile(filename.c_str(), GENERIC_READ, | |
| 421 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, | |
| 422 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)); | |
| 423 return GetFileCreationLocalTimeFromHandle(file_handle.Get(), creation_time); | |
| 424 } | |
| 425 #endif | |
| 426 | |
| 427 bool ReadFromFD(int fd, char* buffer, size_t bytes) { | 399 bool ReadFromFD(int fd, char* buffer, size_t bytes) { |
| 428 size_t total_read = 0; | 400 size_t total_read = 0; |
| 429 while (total_read < bytes) { | 401 while (total_read < bytes) { |
| 430 ssize_t bytes_read = | 402 ssize_t bytes_read = |
| 431 HANDLE_EINTR(read(fd, buffer + total_read, bytes - total_read)); | 403 HANDLE_EINTR(read(fd, buffer + total_read, bytes - total_read)); |
| 432 if (bytes_read <= 0) | 404 if (bytes_read <= 0) |
| 433 break; | 405 break; |
| 434 total_read += bytes_read; | 406 total_read += bytes_read; |
| 435 } | 407 } |
| 436 return total_read == bytes; | 408 return total_read == bytes; |
| (...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1152 | 1124 |
| 1153 allowed_group_ids.insert(group_record->gr_gid); | 1125 allowed_group_ids.insert(group_record->gr_gid); |
| 1154 } | 1126 } |
| 1155 | 1127 |
| 1156 return VerifyPathControlledByUser( | 1128 return VerifyPathControlledByUser( |
| 1157 kFileSystemRoot, path, kRootUid, allowed_group_ids); | 1129 kFileSystemRoot, path, kRootUid, allowed_group_ids); |
| 1158 } | 1130 } |
| 1159 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | 1131 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
| 1160 | 1132 |
| 1161 } // namespace file_util | 1133 } // namespace file_util |
| OLD | NEW |