OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/test/test_file_util.h" | 5 #include "base/test/test_file_util.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <sys/stat.h> |
9 #include <sys/types.h> | 10 #include <sys/types.h> |
10 #include <sys/stat.h> | |
11 | 11 |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/logging.h" | |
15 #include "base/file_path.h" | 14 #include "base/file_path.h" |
16 #include "base/file_util.h" | 15 #include "base/file_util.h" |
| 16 #include "base/logging.h" |
17 #include "base/string_util.h" | 17 #include "base/string_util.h" |
18 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
19 | 19 |
20 namespace file_util { | 20 namespace file_util { |
21 | 21 |
22 bool DieFileDie(const FilePath& file, bool recurse) { | 22 bool DieFileDie(const FilePath& file, bool recurse) { |
23 // There is no need to workaround Windows problems on POSIX. | 23 // There is no need to workaround Windows problems on POSIX. |
24 // Just pass-through. | 24 // Just pass-through. |
25 return file_util::Delete(file, recurse); | 25 return file_util::Delete(file, recurse); |
26 } | 26 } |
(...skipping 15 matching lines...) Expand all Loading... |
42 } else { | 42 } else { |
43 real_to_path = real_to_path.DirName(); | 43 real_to_path = real_to_path.DirName(); |
44 if (!AbsolutePath(&real_to_path)) | 44 if (!AbsolutePath(&real_to_path)) |
45 return false; | 45 return false; |
46 } | 46 } |
47 if (real_to_path.value().compare(0, source_dir.value().size(), | 47 if (real_to_path.value().compare(0, source_dir.value().size(), |
48 source_dir.value()) == 0) | 48 source_dir.value()) == 0) |
49 return false; | 49 return false; |
50 | 50 |
51 bool success = true; | 51 bool success = true; |
52 FileEnumerator::FILE_TYPE traverse_type = | 52 FileEnumerator::FileType traverse_type = |
53 static_cast<FileEnumerator::FILE_TYPE>(FileEnumerator::FILES | | 53 static_cast<FileEnumerator::FileType>(FileEnumerator::FILES | |
54 FileEnumerator::SHOW_SYM_LINKS | FileEnumerator::DIRECTORIES); | 54 FileEnumerator::SHOW_SYM_LINKS | FileEnumerator::DIRECTORIES); |
55 FileEnumerator traversal(source_dir, true, traverse_type); | 55 FileEnumerator traversal(source_dir, true, traverse_type); |
56 | 56 |
57 // dest_dir may not exist yet, start the loop with dest_dir | 57 // dest_dir may not exist yet, start the loop with dest_dir |
58 FileEnumerator::FindInfo info; | 58 FileEnumerator::FindInfo info; |
59 FilePath current = source_dir; | 59 FilePath current = source_dir; |
60 if (stat(source_dir.value().c_str(), &info.stat) < 0) { | 60 if (stat(source_dir.value().c_str(), &info.stat) < 0) { |
61 LOG(ERROR) << "CopyRecursiveDirNoCache() couldn't stat source directory: " | 61 LOG(ERROR) << "CopyRecursiveDirNoCache() couldn't stat source directory: " |
62 << source_dir.value() << " errno = " << errno; | 62 << source_dir.value() << " errno = " << errno; |
63 success = false; | 63 success = false; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 #endif | 111 #endif |
112 | 112 |
113 std::wstring FilePathAsWString(const FilePath& path) { | 113 std::wstring FilePathAsWString(const FilePath& path) { |
114 return UTF8ToWide(path.value()); | 114 return UTF8ToWide(path.value()); |
115 } | 115 } |
116 FilePath WStringAsFilePath(const std::wstring& path) { | 116 FilePath WStringAsFilePath(const std::wstring& path) { |
117 return FilePath(WideToUTF8(path)); | 117 return FilePath(WideToUTF8(path)); |
118 } | 118 } |
119 | 119 |
120 } // namespace file_util | 120 } // namespace file_util |
OLD | NEW |