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

Side by Side Diff: base/file_util_win.cc

Issue 3404018: Add a TouchFile function that operates on FilePaths + fixing a bug... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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 | Annotate | Revision Log
« no previous file with comments | « base/file_util_unittest.cc ('k') | base/platform_file_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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, &timestamp, &timestamp);
705 return ret != 0;
706 }
707
708 FILE* OpenFile(const FilePath& filename, const char* mode) { 699 FILE* OpenFile(const FilePath& filename, const char* mode) {
709 std::wstring w_mode = ASCIIToWide(std::string(mode)); 700 std::wstring w_mode = ASCIIToWide(std::string(mode));
710 return _wfsopen(filename.value().c_str(), w_mode.c_str(), _SH_DENYNO); 701 return _wfsopen(filename.value().c_str(), w_mode.c_str(), _SH_DENYNO);
711 } 702 }
712 703
713 FILE* OpenFile(const std::string& filename, const char* mode) { 704 FILE* OpenFile(const std::string& filename, const char* mode) {
714 return _fsopen(filename.c_str(), mode, _SH_DENYNO); 705 return _fsopen(filename.c_str(), mode, _SH_DENYNO);
715 } 706 }
716 707
717 int ReadFile(const FilePath& filename, char* data, int size) { 708 int ReadFile(const FilePath& filename, char* data, int size) {
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 uint8 unused = *(touch + offset); 1085 uint8 unused = *(touch + offset);
1095 offset += step_size; 1086 offset += step_size;
1096 } 1087 }
1097 FreeLibrary(dll_module); 1088 FreeLibrary(dll_module);
1098 } 1089 }
1099 1090
1100 return true; 1091 return true;
1101 } 1092 }
1102 1093
1103 } // namespace file_util 1094 } // namespace file_util
OLDNEW
« no previous file with comments | « base/file_util_unittest.cc ('k') | base/platform_file_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698