Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: trunk/src/base/test/test_file_util_win.cc

Issue 13958002: Revert 192940 "Delete CopyRecursiveDirNoCache from test_file_util." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « trunk/src/base/test/test_file_util_posix.cc ('k') | trunk/src/chrome/test/automation/proxy_launcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/base/test/test_file_util_win.cc
===================================================================
--- trunk/src/base/test/test_file_util_win.cc (revision 193252)
+++ trunk/src/base/test/test_file_util_win.cc (working copy)
@@ -216,6 +216,59 @@
return true;
}
+// Like CopyFileNoCache but recursively copies all files and subdirectories
+// in the given input directory to the output directory.
+bool CopyRecursiveDirNoCache(const base::FilePath& source_dir,
+ const base::FilePath& dest_dir) {
+ // Try to create the directory if it doesn't already exist.
+ if (!CreateDirectory(dest_dir)) {
+ if (GetLastError() != ERROR_ALREADY_EXISTS)
+ return false;
+ }
+
+ std::vector<std::wstring> files_copied;
+
+ base::FilePath src(source_dir.AppendASCII("*"));
+
+ WIN32_FIND_DATA fd;
+ HANDLE fh = FindFirstFile(src.value().c_str(), &fd);
+ if (fh == INVALID_HANDLE_VALUE)
+ return false;
+
+ do {
+ std::wstring cur_file(fd.cFileName);
+ if (cur_file == L"." || cur_file == L"..")
+ continue; // Skip these special entries.
+
+ base::FilePath cur_source_path = source_dir.Append(cur_file);
+ base::FilePath cur_dest_path = dest_dir.Append(cur_file);
+
+ if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
+ // Recursively copy a subdirectory. We stripped "." and ".." already.
+ if (!CopyRecursiveDirNoCache(cur_source_path, cur_dest_path)) {
+ FindClose(fh);
+ return false;
+ }
+ } else {
+ // Copy the file.
+ if (!::CopyFile(cur_source_path.value().c_str(),
+ cur_dest_path.value().c_str(), false)) {
+ FindClose(fh);
+ return false;
+ }
+
+ // We don't check for errors from this function, often, we are copying
+ // files that are in the repository, and they will have read-only set.
+ // This will prevent us from evicting from the cache, but these don't
+ // matter anyway.
+ EvictFileFromSystemCache(cur_dest_path);
+ }
+ } while (FindNextFile(fh, &fd));
+
+ FindClose(fh);
+ return true;
+}
+
// Checks if the volume supports Alternate Data Streams. This is required for
// the Zone Identifier implementation.
bool VolumeSupportsADS(const base::FilePath& path) {
« no previous file with comments | « trunk/src/base/test/test_file_util_posix.cc ('k') | trunk/src/chrome/test/automation/proxy_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698