| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 ScopedHandle file_handle( | 602 ScopedHandle file_handle( |
| 603 CreateFile(file_path.value().c_str(), FILE_WRITE_ATTRIBUTES, | 603 CreateFile(file_path.value().c_str(), FILE_WRITE_ATTRIBUTES, |
| 604 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, | 604 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, |
| 605 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)); | 605 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)); |
| 606 BOOL ret = SetFileTime(file_handle.Get(), NULL, ×tamp, ×tamp); | 606 BOOL ret = SetFileTime(file_handle.Get(), NULL, ×tamp, ×tamp); |
| 607 return ret != 0; | 607 return ret != 0; |
| 608 } | 608 } |
| 609 | 609 |
| 610 FILE* OpenFile(const FilePath& filename, const char* mode) { | 610 FILE* OpenFile(const FilePath& filename, const char* mode) { |
| 611 std::wstring w_mode = ASCIIToWide(std::string(mode)); | 611 std::wstring w_mode = ASCIIToWide(std::string(mode)); |
| 612 FILE* file; | 612 return _wfsopen(filename.value().c_str(), w_mode.c_str(), _SH_DENYNO); |
| 613 if (_wfopen_s(&file, filename.value().c_str(), w_mode.c_str()) != 0) { | |
| 614 return NULL; | |
| 615 } | |
| 616 return file; | |
| 617 } | 613 } |
| 618 | 614 |
| 619 FILE* OpenFile(const std::string& filename, const char* mode) { | 615 FILE* OpenFile(const std::string& filename, const char* mode) { |
| 620 FILE* file; | 616 return _fsopen(filename.c_str(), mode, _SH_DENYNO); |
| 621 if (fopen_s(&file, filename.c_str(), mode) != 0) { | |
| 622 return NULL; | |
| 623 } | |
| 624 return file; | |
| 625 } | 617 } |
| 626 | 618 |
| 627 int ReadFile(const FilePath& filename, char* data, int size) { | 619 int ReadFile(const FilePath& filename, char* data, int size) { |
| 628 ScopedHandle file(CreateFile(filename.value().c_str(), | 620 ScopedHandle file(CreateFile(filename.value().c_str(), |
| 629 GENERIC_READ, | 621 GENERIC_READ, |
| 630 FILE_SHARE_READ | FILE_SHARE_WRITE, | 622 FILE_SHARE_READ | FILE_SHARE_WRITE, |
| 631 NULL, | 623 NULL, |
| 632 OPEN_EXISTING, | 624 OPEN_EXISTING, |
| 633 FILE_FLAG_SEQUENTIAL_SCAN, | 625 FILE_FLAG_SEQUENTIAL_SCAN, |
| 634 NULL)); | 626 NULL)); |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 878 } | 870 } |
| 879 | 871 |
| 880 bool HasFileBeenModifiedSince(const FileEnumerator::FindInfo& find_info, | 872 bool HasFileBeenModifiedSince(const FileEnumerator::FindInfo& find_info, |
| 881 const base::Time& cutoff_time) { | 873 const base::Time& cutoff_time) { |
| 882 long result = CompareFileTime(&find_info.ftLastWriteTime, | 874 long result = CompareFileTime(&find_info.ftLastWriteTime, |
| 883 &cutoff_time.ToFileTime()); | 875 &cutoff_time.ToFileTime()); |
| 884 return result == 1 || result == 0; | 876 return result == 1 || result == 0; |
| 885 } | 877 } |
| 886 | 878 |
| 887 } // namespace file_util | 879 } // namespace file_util |
| OLD | NEW |