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 <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> |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 } | 53 } |
54 #endif | 54 #endif |
55 | 55 |
56 | 56 |
57 #if defined(GOOGLE_CHROME_BUILD) | 57 #if defined(GOOGLE_CHROME_BUILD) |
58 static const char* kTempFileName = "com.google.chrome.XXXXXX"; | 58 static const char* kTempFileName = "com.google.chrome.XXXXXX"; |
59 #else | 59 #else |
60 static const char* kTempFileName = "org.chromium.XXXXXX"; | 60 static const char* kTempFileName = "org.chromium.XXXXXX"; |
61 #endif | 61 #endif |
62 | 62 |
63 std::wstring GetDirectoryFromPath(const std::wstring& path) { | |
64 if (EndsWithSeparator(path)) { | |
65 return FilePath::FromWStringHack(path) | |
66 .StripTrailingSeparators() | |
67 .ToWStringHack(); | |
68 } else { | |
69 char full_path[PATH_MAX]; | |
70 base::strlcpy(full_path, WideToUTF8(path).c_str(), arraysize(full_path)); | |
71 return UTF8ToWide(dirname(full_path)); | |
72 } | |
73 } | |
74 | |
75 bool AbsolutePath(FilePath* path) { | 63 bool AbsolutePath(FilePath* path) { |
76 char full_path[PATH_MAX]; | 64 char full_path[PATH_MAX]; |
77 if (realpath(path->value().c_str(), full_path) == NULL) | 65 if (realpath(path->value().c_str(), full_path) == NULL) |
78 return false; | 66 return false; |
79 *path = FilePath(full_path); | 67 *path = FilePath(full_path); |
80 return true; | 68 return true; |
81 } | 69 } |
82 | 70 |
83 int CountFilesCreatedAfter(const FilePath& path, | 71 int CountFilesCreatedAfter(const FilePath& path, |
84 const base::Time& comparison_time) { | 72 const base::Time& comparison_time) { |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 length_ = 0; | 701 length_ = 0; |
714 file_ = base::kInvalidPlatformFileValue; | 702 file_ = base::kInvalidPlatformFileValue; |
715 } | 703 } |
716 | 704 |
717 bool HasFileBeenModifiedSince(const FileEnumerator::FindInfo& find_info, | 705 bool HasFileBeenModifiedSince(const FileEnumerator::FindInfo& find_info, |
718 const base::Time& cutoff_time) { | 706 const base::Time& cutoff_time) { |
719 return find_info.stat.st_mtime >= cutoff_time.ToTimeT(); | 707 return find_info.stat.st_mtime >= cutoff_time.ToTimeT(); |
720 } | 708 } |
721 | 709 |
722 } // namespace file_util | 710 } // namespace file_util |
OLD | NEW |