thestig@chromium.org | b2f28d2 | 2012-03-03 01:54:35 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 4 | |
| 5 | #include "base/file_util.h" |
| 6 | |
jeremy@chromium.org | c2c998c | 2009-01-27 19:08:39 | [diff] [blame] | 7 | #if defined(OS_WIN) |
| 8 | #include <io.h> |
| 9 | #endif |
mark@chromium.org | 836f134 | 2008-10-01 17:40:13 | [diff] [blame] | 10 | #include <stdio.h> |
| 11 | |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 12 | #include <fstream> |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 13 | |
brettw@chromium.org | 5799981 | 2013-02-24 05:40:52 | [diff] [blame^] | 14 | #include "base/files/file_path.h" |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 15 | #include "base/logging.h" |
estade@chromium.org | b9e04f0 | 2008-11-27 04:03:57 | [diff] [blame] | 16 | #include "base/string_piece.h" |
brettw@chromium.org | 047a03f | 2009-10-07 02:10:20 | [diff] [blame] | 17 | #include "base/string_util.h" |
brettw@chromium.org | 5799981 | 2013-02-24 05:40:52 | [diff] [blame^] | 18 | #include "base/stringprintf.h" |
brettw@chromium.org | 047a03f | 2009-10-07 02:10:20 | [diff] [blame] | 19 | #include "base/utf_string_conversions.h" |
estade@chromium.org | b9e04f0 | 2008-11-27 04:03:57 | [diff] [blame] | 20 | |
brettw@chromium.org | 04af979a | 2013-02-16 04:12:26 | [diff] [blame] | 21 | using base::FilePath; |
| 22 | |
estade@chromium.org | ceeb87e | 2008-12-04 20:46:06 | [diff] [blame] | 23 | namespace { |
| 24 | |
| 25 | const FilePath::CharType kExtensionSeparator = FILE_PATH_LITERAL('.'); |
jam@chromium.org | e285afa | 2012-01-31 23:16:39 | [diff] [blame] | 26 | |
| 27 | // The maximum number of 'uniquified' files we will try to create. |
| 28 | // This is used when the filename we're trying to download is already in use, |
| 29 | // so we create a new unique filename by appending " (nnn)" before the |
| 30 | // extension, where 1 <= nnn <= kMaxUniqueFiles. |
| 31 | // Also used by code that cleans up said files. |
| 32 | static const int kMaxUniqueFiles = 100; |
estade@chromium.org | ceeb87e | 2008-12-04 20:46:06 | [diff] [blame] | 33 | |
willchan@chromium.org | c145cbdd | 2009-04-24 17:44:39 | [diff] [blame] | 34 | } // namespace |
estade@chromium.org | ceeb87e | 2008-12-04 20:46:06 | [diff] [blame] | 35 | |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 36 | namespace file_util { |
| 37 | |
aa@chromium.org | 354002bb | 2012-02-05 03:22:38 | [diff] [blame] | 38 | bool g_bug108724_debug = false; |
| 39 | |
estade@chromium.org | b9e04f0 | 2008-11-27 04:03:57 | [diff] [blame] | 40 | bool EndsWithSeparator(const FilePath& path) { |
| 41 | FilePath::StringType value = path.value(); |
| 42 | if (value.empty()) |
| 43 | return false; |
| 44 | |
| 45 | return FilePath::IsSeparator(value[value.size() - 1]); |
estade@chromium.org | 7e26394 | 2008-11-25 22:04:37 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | bool EnsureEndsWithSeparator(FilePath* path) { |
| 49 | if (!DirectoryExists(*path)) |
| 50 | return false; |
| 51 | |
| 52 | if (EndsWithSeparator(*path)) |
| 53 | return true; |
| 54 | |
| 55 | FilePath::StringType& path_str = |
| 56 | const_cast<FilePath::StringType&>(path->value()); |
| 57 | path_str.append(&FilePath::kSeparators[0], 1); |
| 58 | |
| 59 | return true; |
glen@chromium.org | 52ab8f90 | 2008-11-03 16:14:46 | [diff] [blame] | 60 | } |
| 61 | |
estade@chromium.org | ceeb87e | 2008-12-04 20:46:06 | [diff] [blame] | 62 | void InsertBeforeExtension(FilePath* path, const FilePath::StringType& suffix) { |
| 63 | FilePath::StringType& value = |
| 64 | const_cast<FilePath::StringType&>(path->value()); |
| 65 | |
| 66 | const FilePath::StringType::size_type last_dot = |
| 67 | value.rfind(kExtensionSeparator); |
| 68 | const FilePath::StringType::size_type last_separator = |
| 69 | value.find_last_of(FilePath::StringType(FilePath::kSeparators)); |
| 70 | |
| 71 | if (last_dot == FilePath::StringType::npos || |
| 72 | (last_separator != std::wstring::npos && last_dot < last_separator)) { |
| 73 | // The path looks something like "C:\pics.old\jojo" or "C:\pics\jojo". |
| 74 | // We should just append the suffix to the entire path. |
| 75 | value.append(suffix); |
| 76 | return; |
| 77 | } |
| 78 | |
| 79 | value.insert(last_dot, suffix); |
| 80 | } |
| 81 | |
cevans@chromium.org | 3cd2c1c | 2013-02-06 20:38:07 | [diff] [blame] | 82 | bool Move(const FilePath& from_path, const FilePath& to_path) { |
| 83 | if (from_path.ReferencesParent() || to_path.ReferencesParent()) |
| 84 | return false; |
| 85 | return MoveUnsafe(from_path, to_path); |
| 86 | } |
| 87 | |
| 88 | bool CopyFile(const FilePath& from_path, const FilePath& to_path) { |
| 89 | if (from_path.ReferencesParent() || to_path.ReferencesParent()) |
| 90 | return false; |
| 91 | return CopyFileUnsafe(from_path, to_path); |
| 92 | } |
| 93 | |
evanm@google.com | 640517f | 2008-10-30 23:54:04 | [diff] [blame] | 94 | bool ContentsEqual(const FilePath& filename1, const FilePath& filename2) { |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 95 | // We open the file in binary format even if they are text files because |
| 96 | // we are just comparing that bytes are exactly same in both files and not |
| 97 | // doing anything smart with text formatting. |
evanm@google.com | 640517f | 2008-10-30 23:54:04 | [diff] [blame] | 98 | std::ifstream file1(filename1.value().c_str(), |
erikkay@google.com | 5af2edb9 | 2008-08-08 20:16:08 | [diff] [blame] | 99 | std::ios::in | std::ios::binary); |
evanm@google.com | 640517f | 2008-10-30 23:54:04 | [diff] [blame] | 100 | std::ifstream file2(filename2.value().c_str(), |
erikkay@google.com | 5af2edb9 | 2008-08-08 20:16:08 | [diff] [blame] | 101 | std::ios::in | std::ios::binary); |
estade@chromium.org | b9e04f0 | 2008-11-27 04:03:57 | [diff] [blame] | 102 | |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 103 | // Even if both files aren't openable (and thus, in some sense, "equal"), |
| 104 | // any unusable file yields a result of "false". |
| 105 | if (!file1.is_open() || !file2.is_open()) |
| 106 | return false; |
| 107 | |
| 108 | const int BUFFER_SIZE = 2056; |
| 109 | char buffer1[BUFFER_SIZE], buffer2[BUFFER_SIZE]; |
| 110 | do { |
| 111 | file1.read(buffer1, BUFFER_SIZE); |
| 112 | file2.read(buffer2, BUFFER_SIZE); |
| 113 | |
mark@chromium.org | b81637c3 | 2009-06-26 21:17:24 | [diff] [blame] | 114 | if ((file1.eof() != file2.eof()) || |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 115 | (file1.gcount() != file2.gcount()) || |
| 116 | (memcmp(buffer1, buffer2, file1.gcount()))) { |
| 117 | file1.close(); |
| 118 | file2.close(); |
| 119 | return false; |
| 120 | } |
mark@chromium.org | b81637c3 | 2009-06-26 21:17:24 | [diff] [blame] | 121 | } while (!file1.eof() || !file2.eof()); |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 122 | |
| 123 | file1.close(); |
| 124 | file2.close(); |
| 125 | return true; |
| 126 | } |
| 127 | |
mark@chromium.org | b81637c3 | 2009-06-26 21:17:24 | [diff] [blame] | 128 | bool TextContentsEqual(const FilePath& filename1, const FilePath& filename2) { |
| 129 | std::ifstream file1(filename1.value().c_str(), std::ios::in); |
| 130 | std::ifstream file2(filename2.value().c_str(), std::ios::in); |
| 131 | |
| 132 | // Even if both files aren't openable (and thus, in some sense, "equal"), |
| 133 | // any unusable file yields a result of "false". |
| 134 | if (!file1.is_open() || !file2.is_open()) |
| 135 | return false; |
| 136 | |
| 137 | do { |
| 138 | std::string line1, line2; |
| 139 | getline(file1, line1); |
| 140 | getline(file2, line2); |
| 141 | |
| 142 | // Check for mismatched EOF states, or any error state. |
| 143 | if ((file1.eof() != file2.eof()) || |
| 144 | file1.bad() || file2.bad()) { |
| 145 | return false; |
| 146 | } |
| 147 | |
| 148 | // Trim all '\r' and '\n' characters from the end of the line. |
| 149 | std::string::size_type end1 = line1.find_last_not_of("\r\n"); |
| 150 | if (end1 == std::string::npos) |
| 151 | line1.clear(); |
| 152 | else if (end1 + 1 < line1.length()) |
| 153 | line1.erase(end1 + 1); |
| 154 | |
| 155 | std::string::size_type end2 = line2.find_last_not_of("\r\n"); |
| 156 | if (end2 == std::string::npos) |
| 157 | line2.clear(); |
| 158 | else if (end2 + 1 < line2.length()) |
| 159 | line2.erase(end2 + 1); |
| 160 | |
| 161 | if (line1 != line2) |
| 162 | return false; |
| 163 | } while (!file1.eof() || !file2.eof()); |
| 164 | |
| 165 | return true; |
| 166 | } |
| 167 | |
erikkay@google.com | 3c528102 | 2009-01-28 00:22:46 | [diff] [blame] | 168 | bool ReadFileToString(const FilePath& path, std::string* contents) { |
cpu@chromium.org | 9fea5a9 | 2013-01-09 00:38:59 | [diff] [blame] | 169 | if (path.ReferencesParent()) |
| 170 | return false; |
mark@chromium.org | 836f134 | 2008-10-01 17:40:13 | [diff] [blame] | 171 | FILE* file = OpenFile(path, "rb"); |
| 172 | if (!file) { |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 173 | return false; |
mark@chromium.org | 836f134 | 2008-10-01 17:40:13 | [diff] [blame] | 174 | } |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 175 | |
| 176 | char buf[1 << 16]; |
| 177 | size_t len; |
| 178 | while ((len = fread(buf, 1, sizeof(buf), file)) > 0) { |
evan@chromium.org | 4e074bae | 2010-05-19 11:07:55 | [diff] [blame] | 179 | if (contents) |
| 180 | contents->append(buf, len); |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 181 | } |
mark@chromium.org | 836f134 | 2008-10-01 17:40:13 | [diff] [blame] | 182 | CloseFile(file); |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 183 | |
| 184 | return true; |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 185 | } |
| 186 | |
tfarina@chromium.org | b33f1d9 | 2010-05-26 01:40:12 | [diff] [blame] | 187 | bool IsDirectoryEmpty(const FilePath& dir_path) { |
| 188 | FileEnumerator files(dir_path, false, |
haruki@chromium.org | 84c3f16 | 2012-08-12 01:57:23 | [diff] [blame] | 189 | FileEnumerator::FILES | FileEnumerator::DIRECTORIES); |
tfarina@chromium.org | b33f1d9 | 2010-05-26 01:40:12 | [diff] [blame] | 190 | if (files.Next().value().empty()) |
| 191 | return true; |
| 192 | return false; |
| 193 | } |
| 194 | |
phajdan.jr@chromium.org | 6faa0e0d | 2009-04-28 06:50:36 | [diff] [blame] | 195 | FILE* CreateAndOpenTemporaryFile(FilePath* path) { |
| 196 | FilePath directory; |
| 197 | if (!GetTempDir(&directory)) |
evan@chromium.org | 628476aa | 2010-06-10 22:56:23 | [diff] [blame] | 198 | return NULL; |
phajdan.jr@chromium.org | 6faa0e0d | 2009-04-28 06:50:36 | [diff] [blame] | 199 | |
| 200 | return CreateAndOpenTemporaryFileInDir(directory, path); |
| 201 | } |
| 202 | |
dkegel@google.com | eac0709a | 2008-11-04 21:00:46 | [diff] [blame] | 203 | bool GetFileSize(const FilePath& file_path, int64* file_size) { |
dumi@chromium.org | 2f0193c2 | 2010-09-03 02:28:37 | [diff] [blame] | 204 | base::PlatformFileInfo info; |
darin@google.com | f5e3da4d | 2008-09-26 01:04:08 | [diff] [blame] | 205 | if (!GetFileInfo(file_path, &info)) |
| 206 | return false; |
| 207 | *file_size = info.size; |
| 208 | return true; |
| 209 | } |
| 210 | |
estade@chromium.org | 1525c68 | 2010-02-11 23:27:47 | [diff] [blame] | 211 | bool IsDot(const FilePath& path) { |
| 212 | return FILE_PATH_LITERAL(".") == path.BaseName().value(); |
| 213 | } |
| 214 | |
| 215 | bool IsDotDot(const FilePath& path) { |
| 216 | return FILE_PATH_LITERAL("..") == path.BaseName().value(); |
| 217 | } |
| 218 | |
dumi@chromium.org | 507fb9a | 2010-09-23 23:28:22 | [diff] [blame] | 219 | bool TouchFile(const FilePath& path, |
| 220 | const base::Time& last_accessed, |
| 221 | const base::Time& last_modified) { |
nhiroki@chromium.org | 307a825a | 2012-11-01 11:48:52 | [diff] [blame] | 222 | int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE_ATTRIBUTES; |
| 223 | |
| 224 | #if defined(OS_WIN) |
| 225 | // On Windows, FILE_FLAG_BACKUP_SEMANTICS is needed to open a directory. |
| 226 | if (DirectoryExists(path)) |
| 227 | flags |= base::PLATFORM_FILE_BACKUP_SEMANTICS; |
| 228 | #endif // OS_WIN |
| 229 | |
| 230 | const base::PlatformFile file = |
| 231 | base::CreatePlatformFile(path, flags, NULL, NULL); |
dumi@chromium.org | 507fb9a | 2010-09-23 23:28:22 | [diff] [blame] | 232 | if (file != base::kInvalidPlatformFileValue) { |
| 233 | bool result = base::TouchPlatformFile(file, last_accessed, last_modified); |
| 234 | base::ClosePlatformFile(file); |
| 235 | return result; |
| 236 | } |
| 237 | |
| 238 | return false; |
| 239 | } |
| 240 | |
| 241 | bool SetLastModifiedTime(const FilePath& path, |
| 242 | const base::Time& last_modified) { |
| 243 | return TouchFile(path, last_modified, last_modified); |
| 244 | } |
| 245 | |
mark@chromium.org | 836f134 | 2008-10-01 17:40:13 | [diff] [blame] | 246 | bool CloseFile(FILE* file) { |
sidchat@google.com | a1a1950 | 2008-10-21 17:14:45 | [diff] [blame] | 247 | if (file == NULL) |
| 248 | return true; |
mark@chromium.org | 836f134 | 2008-10-01 17:40:13 | [diff] [blame] | 249 | return fclose(file) == 0; |
jeremy@chromium.org | 6e01dae | 2009-01-27 17:13:02 | [diff] [blame] | 250 | } |
| 251 | |
jeremy@chromium.org | c2c998c | 2009-01-27 19:08:39 | [diff] [blame] | 252 | bool TruncateFile(FILE* file) { |
| 253 | if (file == NULL) |
| 254 | return false; |
| 255 | long current_offset = ftell(file); |
| 256 | if (current_offset == -1) |
| 257 | return false; |
| 258 | #if defined(OS_WIN) |
| 259 | int fd = _fileno(file); |
| 260 | if (_chsize(fd, current_offset) != 0) |
| 261 | return false; |
| 262 | #else |
| 263 | int fd = fileno(file); |
| 264 | if (ftruncate(fd, current_offset) != 0) |
| 265 | return false; |
| 266 | #endif |
| 267 | return true; |
| 268 | } |
| 269 | |
jam@chromium.org | e285afa | 2012-01-31 23:16:39 | [diff] [blame] | 270 | int GetUniquePathNumber( |
| 271 | const FilePath& path, |
| 272 | const FilePath::StringType& suffix) { |
| 273 | bool have_suffix = !suffix.empty(); |
| 274 | if (!PathExists(path) && |
| 275 | (!have_suffix || !PathExists(FilePath(path.value() + suffix)))) { |
| 276 | return 0; |
| 277 | } |
| 278 | |
| 279 | FilePath new_path; |
| 280 | for (int count = 1; count <= kMaxUniqueFiles; ++count) { |
| 281 | new_path = path.InsertBeforeExtensionASCII(StringPrintf(" (%d)", count)); |
| 282 | if (!PathExists(new_path) && |
| 283 | (!have_suffix || !PathExists(FilePath(new_path.value() + suffix)))) { |
| 284 | return count; |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | return -1; |
| 289 | } |
| 290 | |
aa@chromium.org | ee5c29da | 2009-01-09 22:14:27 | [diff] [blame] | 291 | bool ContainsPath(const FilePath &parent, const FilePath& child) { |
| 292 | FilePath abs_parent = FilePath(parent); |
| 293 | FilePath abs_child = FilePath(child); |
| 294 | |
| 295 | if (!file_util::AbsolutePath(&abs_parent) || |
| 296 | !file_util::AbsolutePath(&abs_child)) |
| 297 | return false; |
| 298 | |
| 299 | #if defined(OS_WIN) |
| 300 | // file_util::AbsolutePath() does not flatten case on Windows, so we must do |
| 301 | // a case-insensitive compare. |
| 302 | if (!StartsWith(abs_child.value(), abs_parent.value(), false)) |
| 303 | #else |
| 304 | if (!StartsWithASCII(abs_child.value(), abs_parent.value(), true)) |
| 305 | #endif |
| 306 | return false; |
| 307 | |
| 308 | // file_util::AbsolutePath() normalizes '/' to '\' on Windows, so we only need |
| 309 | // to check kSeparators[0]. |
| 310 | if (abs_child.value().length() <= abs_parent.value().length() || |
| 311 | abs_child.value()[abs_parent.value().length()] != |
| 312 | FilePath::kSeparators[0]) |
| 313 | return false; |
| 314 | |
| 315 | return true; |
| 316 | } |
| 317 | |
cpu@chromium.org | c2c132c | 2010-03-24 21:56:26 | [diff] [blame] | 318 | int64 ComputeDirectorySize(const FilePath& root_path) { |
| 319 | int64 running_size = 0; |
| 320 | FileEnumerator file_iter(root_path, true, FileEnumerator::FILES); |
| 321 | for (FilePath current = file_iter.Next(); !current.empty(); |
| 322 | current = file_iter.Next()) { |
| 323 | FileEnumerator::FindInfo info; |
| 324 | file_iter.GetFindInfo(&info); |
| 325 | #if defined(OS_WIN) |
| 326 | LARGE_INTEGER li = { info.nFileSizeLow, info.nFileSizeHigh }; |
| 327 | running_size += li.QuadPart; |
| 328 | #else |
| 329 | running_size += info.stat.st_size; |
| 330 | #endif |
| 331 | } |
| 332 | return running_size; |
| 333 | } |
| 334 | |
rvargas@google.com | a04876b | 2010-06-11 22:53:43 | [diff] [blame] | 335 | int64 ComputeFilesSize(const FilePath& directory, |
| 336 | const FilePath::StringType& pattern) { |
| 337 | int64 running_size = 0; |
| 338 | FileEnumerator file_iter(directory, false, FileEnumerator::FILES, pattern); |
| 339 | for (FilePath current = file_iter.Next(); !current.empty(); |
| 340 | current = file_iter.Next()) { |
| 341 | FileEnumerator::FindInfo info; |
| 342 | file_iter.GetFindInfo(&info); |
| 343 | #if defined(OS_WIN) |
| 344 | LARGE_INTEGER li = { info.nFileSizeLow, info.nFileSizeHigh }; |
| 345 | running_size += li.QuadPart; |
| 346 | #else |
| 347 | running_size += info.stat.st_size; |
| 348 | #endif |
| 349 | } |
| 350 | return running_size; |
| 351 | } |
| 352 | |
estade@chromium.org | 7856bb8 | 2008-12-12 23:43:03 | [diff] [blame] | 353 | /////////////////////////////////////////////// |
| 354 | // MemoryMappedFile |
| 355 | |
| 356 | MemoryMappedFile::~MemoryMappedFile() { |
| 357 | CloseHandles(); |
| 358 | } |
| 359 | |
erg@google.com | eae9c06 | 2011-01-11 00:50:59 | [diff] [blame] | 360 | bool MemoryMappedFile::Initialize(const FilePath& file_name) { |
| 361 | if (IsValid()) |
| 362 | return false; |
| 363 | |
| 364 | if (!MapFileToMemory(file_name)) { |
| 365 | CloseHandles(); |
| 366 | return false; |
| 367 | } |
| 368 | |
| 369 | return true; |
| 370 | } |
| 371 | |
estade@chromium.org | cb6037d | 2009-11-16 22:55:17 | [diff] [blame] | 372 | bool MemoryMappedFile::Initialize(base::PlatformFile file) { |
| 373 | if (IsValid()) |
| 374 | return false; |
| 375 | |
| 376 | file_ = file; |
| 377 | |
| 378 | if (!MapFileToMemoryInternal()) { |
| 379 | CloseHandles(); |
| 380 | return false; |
| 381 | } |
| 382 | |
| 383 | return true; |
| 384 | } |
| 385 | |
tommi@chromium.org | e318fe5 | 2011-02-23 21:42:48 | [diff] [blame] | 386 | bool MemoryMappedFile::IsValid() const { |
erg@google.com | eae9c06 | 2011-01-11 00:50:59 | [diff] [blame] | 387 | return data_ != NULL; |
estade@chromium.org | 4e1c76f | 2009-11-13 01:36:50 | [diff] [blame] | 388 | } |
| 389 | |
estade@chromium.org | cb6037d | 2009-11-16 22:55:17 | [diff] [blame] | 390 | bool MemoryMappedFile::MapFileToMemory(const FilePath& file_name) { |
dumi@chromium.org | ed65fec | 2010-08-31 19:30:27 | [diff] [blame] | 391 | file_ = base::CreatePlatformFile( |
| 392 | file_name, base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, |
| 393 | NULL, NULL); |
estade@chromium.org | cb6037d | 2009-11-16 22:55:17 | [diff] [blame] | 394 | |
| 395 | if (file_ == base::kInvalidPlatformFileValue) { |
brettw@chromium.org | a42d463 | 2011-10-26 21:48:00 | [diff] [blame] | 396 | DLOG(ERROR) << "Couldn't open " << file_name.value(); |
estade@chromium.org | cb6037d | 2009-11-16 22:55:17 | [diff] [blame] | 397 | return false; |
| 398 | } |
| 399 | |
| 400 | return MapFileToMemoryInternal(); |
estade@chromium.org | 7856bb8 | 2008-12-12 23:43:03 | [diff] [blame] | 401 | } |
| 402 | |
yuzo@chromium.org | 8199b3a | 2009-06-09 05:57:38 | [diff] [blame] | 403 | /////////////////////////////////////////////// |
| 404 | // FileEnumerator |
| 405 | // |
| 406 | // Note: the main logic is in file_util_<platform>.cc |
| 407 | |
| 408 | bool FileEnumerator::ShouldSkip(const FilePath& path) { |
| 409 | FilePath::StringType basename = path.BaseName().value(); |
| 410 | return IsDot(path) || (IsDotDot(path) && !(INCLUDE_DOT_DOT & file_type_)); |
yuzo@chromium.org | 8199b3a | 2009-06-09 05:57:38 | [diff] [blame] | 411 | } |
| 412 | |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 413 | } // namespace |