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 <psapi.h> | 9 #include <psapi.h> |
10 #include <shellapi.h> | 10 #include <shellapi.h> |
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 | 689 |
690 results->is_directory = | 690 results->is_directory = |
691 (attr.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; | 691 (attr.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; |
692 results->last_modified = base::Time::FromFileTime(attr.ftLastWriteTime); | 692 results->last_modified = base::Time::FromFileTime(attr.ftLastWriteTime); |
693 results->last_accessed = base::Time::FromFileTime(attr.ftLastAccessTime); | 693 results->last_accessed = base::Time::FromFileTime(attr.ftLastAccessTime); |
694 results->creation_time = base::Time::FromFileTime(attr.ftCreationTime); | 694 results->creation_time = base::Time::FromFileTime(attr.ftCreationTime); |
695 | 695 |
696 return true; | 696 return true; |
697 } | 697 } |
698 | 698 |
| 699 bool SetLastModifiedTime(const FilePath& file_path, base::Time last_modified) { |
| 700 FILETIME timestamp(last_modified.ToFileTime()); |
| 701 ScopedHandle file_handle( |
| 702 CreateFile(file_path.value().c_str(), FILE_WRITE_ATTRIBUTES, |
| 703 kFileShareAll, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)); |
| 704 BOOL ret = SetFileTime(file_handle.Get(), NULL, ×tamp, ×tamp); |
| 705 return ret != 0; |
| 706 } |
| 707 |
699 FILE* OpenFile(const FilePath& filename, const char* mode) { | 708 FILE* OpenFile(const FilePath& filename, const char* mode) { |
700 std::wstring w_mode = ASCIIToWide(std::string(mode)); | 709 std::wstring w_mode = ASCIIToWide(std::string(mode)); |
701 return _wfsopen(filename.value().c_str(), w_mode.c_str(), _SH_DENYNO); | 710 return _wfsopen(filename.value().c_str(), w_mode.c_str(), _SH_DENYNO); |
702 } | 711 } |
703 | 712 |
704 FILE* OpenFile(const std::string& filename, const char* mode) { | 713 FILE* OpenFile(const std::string& filename, const char* mode) { |
705 return _fsopen(filename.c_str(), mode, _SH_DENYNO); | 714 return _fsopen(filename.c_str(), mode, _SH_DENYNO); |
706 } | 715 } |
707 | 716 |
708 int ReadFile(const FilePath& filename, char* data, int size) { | 717 int ReadFile(const FilePath& filename, char* data, int size) { |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1085 uint8 unused = *(touch + offset); | 1094 uint8 unused = *(touch + offset); |
1086 offset += step_size; | 1095 offset += step_size; |
1087 } | 1096 } |
1088 FreeLibrary(dll_module); | 1097 FreeLibrary(dll_module); |
1089 } | 1098 } |
1090 | 1099 |
1091 return true; | 1100 return true; |
1092 } | 1101 } |
1093 | 1102 |
1094 } // namespace file_util | 1103 } // namespace file_util |
OLD | NEW |