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

Side by Side Diff: base/file_util_posix.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.h ('k') | base/file_util_unittest.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) 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 <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>
11 #include <libgen.h> 11 #include <libgen.h>
12 #include <stdio.h> 12 #include <stdio.h>
13 #include <string.h> 13 #include <string.h>
14 #include <sys/errno.h> 14 #include <sys/errno.h>
15 #include <sys/mman.h> 15 #include <sys/mman.h>
16 #include <sys/stat.h> 16 #include <sys/stat.h>
17 #include <sys/time.h>
17 #include <sys/types.h> 18 #include <sys/types.h>
18 #include <time.h> 19 #include <time.h>
19 #include <unistd.h> 20 #include <unistd.h>
20 21
21 #if defined(OS_MACOSX) 22 #if defined(OS_MACOSX)
22 #include <AvailabilityMacros.h> 23 #include <AvailabilityMacros.h>
23 #endif 24 #endif
24 25
25 #include <fstream> 26 #include <fstream>
26 27
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 bool GetFileInfo(const FilePath& file_path, FileInfo* results) { 452 bool GetFileInfo(const FilePath& file_path, FileInfo* results) {
452 stat_wrapper_t file_info; 453 stat_wrapper_t file_info;
453 if (CallStat(file_path.value().c_str(), &file_info) != 0) 454 if (CallStat(file_path.value().c_str(), &file_info) != 0)
454 return false; 455 return false;
455 results->is_directory = S_ISDIR(file_info.st_mode); 456 results->is_directory = S_ISDIR(file_info.st_mode);
456 results->size = file_info.st_size; 457 results->size = file_info.st_size;
457 results->last_modified = base::Time::FromTimeT(file_info.st_mtime); 458 results->last_modified = base::Time::FromTimeT(file_info.st_mtime);
458 return true; 459 return true;
459 } 460 }
460 461
462 bool SetLastModifiedTime(const FilePath& file_path, base::Time last_modified) {
463 struct timeval times[2];
464 times[0] = last_modified.ToTimeVal();
465 times[1] = last_modified.ToTimeVal();
466 return (utimes(file_path.value().c_str(), times) == 0);
467 }
468
461 bool GetInode(const FilePath& path, ino_t* inode) { 469 bool GetInode(const FilePath& path, ino_t* inode) {
462 struct stat buffer; 470 struct stat buffer;
463 int result = stat(path.value().c_str(), &buffer); 471 int result = stat(path.value().c_str(), &buffer);
464 if (result < 0) 472 if (result < 0)
465 return false; 473 return false;
466 474
467 *inode = buffer.st_ino; 475 *inode = buffer.st_ino;
468 return true; 476 return true;
469 } 477 }
470 478
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 length_ = 0; 713 length_ = 0;
706 file_ = base::kInvalidPlatformFileValue; 714 file_ = base::kInvalidPlatformFileValue;
707 } 715 }
708 716
709 bool HasFileBeenModifiedSince(const FileEnumerator::FindInfo& find_info, 717 bool HasFileBeenModifiedSince(const FileEnumerator::FindInfo& find_info,
710 const base::Time& cutoff_time) { 718 const base::Time& cutoff_time) {
711 return find_info.stat.st_mtime >= cutoff_time.ToTimeT(); 719 return find_info.stat.st_mtime >= cutoff_time.ToTimeT();
712 } 720 }
713 721
714 } // namespace file_util 722 } // namespace file_util
OLDNEW
« no previous file with comments | « base/file_util.h ('k') | base/file_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698