Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <io.h> | 8 #include <io.h> |
| 9 #endif | 9 #endif |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 line2.erase(end2 + 1); | 145 line2.erase(end2 + 1); |
| 146 | 146 |
| 147 if (line1 != line2) | 147 if (line1 != line2) |
| 148 return false; | 148 return false; |
| 149 } while (!file1.eof() || !file2.eof()); | 149 } while (!file1.eof() || !file2.eof()); |
| 150 | 150 |
| 151 return true; | 151 return true; |
| 152 } | 152 } |
| 153 | 153 |
| 154 bool ReadFileToString(const FilePath& path, std::string* contents) { | 154 bool ReadFileToString(const FilePath& path, std::string* contents) { |
| 155 if (path.ReferencesParent()) | |
|
Nico
2013/01/08 19:20:03
Should this DCHECK(), so that devs trying to do th
| |
| 156 return false; | |
| 155 FILE* file = OpenFile(path, "rb"); | 157 FILE* file = OpenFile(path, "rb"); |
| 156 if (!file) { | 158 if (!file) { |
| 157 return false; | 159 return false; |
| 158 } | 160 } |
| 159 | 161 |
| 160 char buf[1 << 16]; | 162 char buf[1 << 16]; |
| 161 size_t len; | 163 size_t len; |
| 162 while ((len = fread(buf, 1, sizeof(buf), file)) > 0) { | 164 while ((len = fread(buf, 1, sizeof(buf), file)) > 0) { |
| 163 if (contents) | 165 if (contents) |
| 164 contents->append(buf, len); | 166 contents->append(buf, len); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 388 // FileEnumerator | 390 // FileEnumerator |
| 389 // | 391 // |
| 390 // Note: the main logic is in file_util_<platform>.cc | 392 // Note: the main logic is in file_util_<platform>.cc |
| 391 | 393 |
| 392 bool FileEnumerator::ShouldSkip(const FilePath& path) { | 394 bool FileEnumerator::ShouldSkip(const FilePath& path) { |
| 393 FilePath::StringType basename = path.BaseName().value(); | 395 FilePath::StringType basename = path.BaseName().value(); |
| 394 return IsDot(path) || (IsDotDot(path) && !(INCLUDE_DOT_DOT & file_type_)); | 396 return IsDot(path) || (IsDotDot(path) && !(INCLUDE_DOT_DOT & file_type_)); |
| 395 } | 397 } |
| 396 | 398 |
| 397 } // namespace | 399 } // namespace |
| OLD | NEW |