diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-06 21:24:20 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-06 21:24:20 +0000 |
commit | 6a48fb51b8f5f627781177ec8af1cf1c56a03abe (patch) | |
tree | de891e2d1189c58be61101dd74a05d49b147c5f4 /base/test/test_file_util_posix.cc | |
parent | 7c056098ec8854a56ad774e1e54b6b40923e5e8b (diff) | |
download | chromium_src-6a48fb51b8f5f627781177ec8af1cf1c56a03abe.zip chromium_src-6a48fb51b8f5f627781177ec8af1cf1c56a03abe.tar.gz chromium_src-6a48fb51b8f5f627781177ec8af1cf1c56a03abe.tar.bz2 |
Delete CopyRecursiveDirNoCache from test_file_util.
This function was used in only one place and the implementation was
copy-and-pasted. This replaces the call with a cross-platform implementation in
the one file that needs it.
This is a reland of r194664 which was a reland of r192940. This version does
not attempt to fix the startup test caching bugs I discovered when rewriting
the function. I filed bug 237904 for this.
BUG=
Review URL: https://codereview.chromium.org/14577009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198539 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/test/test_file_util_posix.cc')
-rw-r--r-- | base/test/test_file_util_posix.cc | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/base/test/test_file_util_posix.cc b/base/test/test_file_util_posix.cc index 731d976..7c16cb18 100644 --- a/base/test/test_file_util_posix.cc +++ b/base/test/test_file_util_posix.cc @@ -80,83 +80,6 @@ bool DieFileDie(const base::FilePath& file, bool recurse) { return file_util::Delete(file, recurse); } -// Mostly a verbatim copy of CopyDirectory -bool CopyRecursiveDirNoCache(const base::FilePath& source_dir, - const base::FilePath& dest_dir) { - char top_dir[PATH_MAX]; - if (base::strlcpy(top_dir, source_dir.value().c_str(), - arraysize(top_dir)) >= arraysize(top_dir)) { - return false; - } - - // This function does not properly handle destinations within the source - base::FilePath real_to_path = dest_dir; - if (PathExists(real_to_path)) { - real_to_path = MakeAbsoluteFilePath(real_to_path); - if (real_to_path.empty()) - return false; - } else { - real_to_path = MakeAbsoluteFilePath(real_to_path.DirName()); - if (real_to_path.empty()) - return false; - } - if (real_to_path.value().compare(0, source_dir.value().size(), - source_dir.value()) == 0) - return false; - - bool success = true; - int traverse_type = FileEnumerator::FILES | - FileEnumerator::SHOW_SYM_LINKS | FileEnumerator::DIRECTORIES; - FileEnumerator traversal(source_dir, true, traverse_type); - - // dest_dir may not exist yet, start the loop with dest_dir - FileEnumerator::FindInfo info; - base::FilePath current = source_dir; - if (stat(source_dir.value().c_str(), &info.stat) < 0) { - DLOG(ERROR) << "CopyRecursiveDirNoCache() couldn't stat source directory: " - << source_dir.value() << " errno = " << errno; - success = false; - } - - while (success && !current.empty()) { - // |current| is the source path, including source_dir, so paste - // the suffix after source_dir onto dest_dir to create the target_path. - std::string suffix(¤t.value().c_str()[source_dir.value().size()]); - // Strip the leading '/' (if any). - if (!suffix.empty()) { - DCHECK_EQ('/', suffix[0]); - suffix.erase(0, 1); - } - const base::FilePath target_path = dest_dir.Append(suffix); - - if (S_ISDIR(info.stat.st_mode)) { - if (mkdir(target_path.value().c_str(), info.stat.st_mode & 01777) != 0 && - errno != EEXIST) { - DLOG(ERROR) << "CopyRecursiveDirNoCache() couldn't create directory: " - << target_path.value() << " errno = " << errno; - success = false; - } - } else if (S_ISREG(info.stat.st_mode)) { - if (CopyFile(current, target_path)) { - success = EvictFileFromSystemCache(target_path); - DCHECK(success); - } else { - DLOG(ERROR) << "CopyRecursiveDirNoCache() couldn't create file: " - << target_path.value(); - success = false; - } - } else { - DLOG(WARNING) << "CopyRecursiveDirNoCache() skipping non-regular file: " - << current.value(); - } - - current = traversal.Next(); - traversal.GetFindInfo(&info); - } - - return success; -} - #if !defined(OS_LINUX) && !defined(OS_MACOSX) bool EvictFileFromSystemCache(const base::FilePath& file) { // There doesn't seem to be a POSIX way to cool the disk cache. |