| OLD | NEW |
| 1 // Copyright (c) 2006-2009 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 #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> |
| 11 | 11 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 if (contents) | 189 if (contents) |
| 190 contents->append(buf, len); | 190 contents->append(buf, len); |
| 191 } | 191 } |
| 192 CloseFile(file); | 192 CloseFile(file); |
| 193 | 193 |
| 194 return true; | 194 return true; |
| 195 } | 195 } |
| 196 | 196 |
| 197 bool IsDirectoryEmpty(const FilePath& dir_path) { |
| 198 FileEnumerator files(dir_path, false, |
| 199 static_cast<FileEnumerator::FILE_TYPE>( |
| 200 FileEnumerator::FILES | FileEnumerator::DIRECTORIES)); |
| 201 if (files.Next().value().empty()) |
| 202 return true; |
| 203 return false; |
| 204 } |
| 205 |
| 197 FILE* CreateAndOpenTemporaryFile(FilePath* path) { | 206 FILE* CreateAndOpenTemporaryFile(FilePath* path) { |
| 198 FilePath directory; | 207 FilePath directory; |
| 199 if (!GetTempDir(&directory)) | 208 if (!GetTempDir(&directory)) |
| 200 return false; | 209 return false; |
| 201 | 210 |
| 202 return CreateAndOpenTemporaryFileInDir(directory, path); | 211 return CreateAndOpenTemporaryFileInDir(directory, path); |
| 203 } | 212 } |
| 204 | 213 |
| 205 bool GetFileSize(const FilePath& file_path, int64* file_size) { | 214 bool GetFileSize(const FilePath& file_path, int64* file_size) { |
| 206 FileInfo info; | 215 FileInfo info; |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 // FileEnumerator | 432 // FileEnumerator |
| 424 // | 433 // |
| 425 // Note: the main logic is in file_util_<platform>.cc | 434 // Note: the main logic is in file_util_<platform>.cc |
| 426 | 435 |
| 427 bool FileEnumerator::ShouldSkip(const FilePath& path) { | 436 bool FileEnumerator::ShouldSkip(const FilePath& path) { |
| 428 FilePath::StringType basename = path.BaseName().value(); | 437 FilePath::StringType basename = path.BaseName().value(); |
| 429 return IsDot(path) || (IsDotDot(path) && !(INCLUDE_DOT_DOT & file_type_)); | 438 return IsDot(path) || (IsDotDot(path) && !(INCLUDE_DOT_DOT & file_type_)); |
| 430 } | 439 } |
| 431 | 440 |
| 432 } // namespace | 441 } // namespace |
| OLD | NEW |