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

Side by Side Diff: base/file_util_win.cc

Issue 600104: Actually delete databases in CookiesTreeModel. (Closed)
Patch Set: fixed comments Created 10 years, 10 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
« no previous file with comments | « base/file_util_unittest.cc ('k') | base/time.h » ('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) 2006-2008 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>
11 #include <time.h> 11 #include <time.h>
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 size.LowPart = attr.nFileSizeLow; 582 size.LowPart = attr.nFileSizeLow;
583 results->size = size.QuadPart; 583 results->size = size.QuadPart;
584 584
585 results->is_directory = 585 results->is_directory =
586 (attr.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; 586 (attr.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
587 results->last_modified = base::Time::FromFileTime(attr.ftLastWriteTime); 587 results->last_modified = base::Time::FromFileTime(attr.ftLastWriteTime);
588 588
589 return true; 589 return true;
590 } 590 }
591 591
592 bool SetLastModifiedTime(const FilePath& file_path, base::Time last_modified) {
593 FILETIME timestamp(last_modified.ToFileTime());
594 ScopedHandle file_handle(
595 CreateFile(file_path.value().c_str(), FILE_WRITE_ATTRIBUTES,
596 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL,
597 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL));
598 BOOL ret = SetFileTime(file_handle.Get(), NULL, &timestamp, &timestamp);
599 return ret != 0;
600 }
601
592 FILE* OpenFile(const FilePath& filename, const char* mode) { 602 FILE* OpenFile(const FilePath& filename, const char* mode) {
593 std::wstring w_mode = ASCIIToWide(std::string(mode)); 603 std::wstring w_mode = ASCIIToWide(std::string(mode));
594 FILE* file; 604 FILE* file;
595 if (_wfopen_s(&file, filename.value().c_str(), w_mode.c_str()) != 0) { 605 if (_wfopen_s(&file, filename.value().c_str(), w_mode.c_str()) != 0) {
596 return NULL; 606 return NULL;
597 } 607 }
598 return file; 608 return file;
599 } 609 }
600 610
601 FILE* OpenFile(const std::string& filename, const char* mode) { 611 FILE* OpenFile(const std::string& filename, const char* mode) {
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 } 870 }
861 871
862 bool HasFileBeenModifiedSince(const FileEnumerator::FindInfo& find_info, 872 bool HasFileBeenModifiedSince(const FileEnumerator::FindInfo& find_info,
863 const base::Time& cutoff_time) { 873 const base::Time& cutoff_time) {
864 long result = CompareFileTime(&find_info.ftLastWriteTime, 874 long result = CompareFileTime(&find_info.ftLastWriteTime,
865 &cutoff_time.ToFileTime()); 875 &cutoff_time.ToFileTime());
866 return result == 1 || result == 0; 876 return result == 1 || result == 0;
867 } 877 }
868 878
869 } // namespace file_util 879 } // namespace file_util
OLDNEW
« no previous file with comments | « base/file_util_unittest.cc ('k') | base/time.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698