OLD | NEW |
---|---|
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
179 | 179 |
180 bool ReadFileToString(const FilePath& path, std::string* contents) { | 180 bool ReadFileToString(const FilePath& path, std::string* contents) { |
181 FILE* file = OpenFile(path, "rb"); | 181 FILE* file = OpenFile(path, "rb"); |
182 if (!file) { | 182 if (!file) { |
183 return false; | 183 return false; |
184 } | 184 } |
185 | 185 |
186 char buf[1 << 16]; | 186 char buf[1 << 16]; |
187 size_t len; | 187 size_t len; |
188 while ((len = fread(buf, 1, sizeof(buf), file)) > 0) { | 188 while ((len = fread(buf, 1, sizeof(buf), file)) > 0) { |
189 contents->append(buf, len); | 189 if (contents) |
jorlow
2010/05/19 10:41:50
This feels dirty to me. I understand what you're
Mark Mentovai
2010/05/19 14:00:27
This does not feel dirty to me at all.
| |
190 contents->append(buf, len); | |
190 } | 191 } |
191 CloseFile(file); | 192 CloseFile(file); |
192 | 193 |
193 return true; | 194 return true; |
194 } | 195 } |
195 | 196 |
196 FILE* CreateAndOpenTemporaryFile(FilePath* path) { | 197 FILE* CreateAndOpenTemporaryFile(FilePath* path) { |
197 FilePath directory; | 198 FilePath directory; |
198 if (!GetTempDir(&directory)) | 199 if (!GetTempDir(&directory)) |
199 return false; | 200 return false; |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
422 // FileEnumerator | 423 // FileEnumerator |
423 // | 424 // |
424 // Note: the main logic is in file_util_<platform>.cc | 425 // Note: the main logic is in file_util_<platform>.cc |
425 | 426 |
426 bool FileEnumerator::ShouldSkip(const FilePath& path) { | 427 bool FileEnumerator::ShouldSkip(const FilePath& path) { |
427 FilePath::StringType basename = path.BaseName().value(); | 428 FilePath::StringType basename = path.BaseName().value(); |
428 return IsDot(path) || (IsDotDot(path) && !(INCLUDE_DOT_DOT & file_type_)); | 429 return IsDot(path) || (IsDotDot(path) && !(INCLUDE_DOT_DOT & file_type_)); |
429 } | 430 } |
430 | 431 |
431 } // namespace | 432 } // namespace |
OLD | NEW |