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

Side by Side Diff: base/test/test_file_util_posix.cc

Issue 8368009: Replace most LOG statements with DLOG statements in base. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/test/test_file_util_mac.cc ('k') | base/threading/non_thread_safe_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 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/stat.h>
10 #include <sys/types.h> 10 #include <sys/types.h>
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 bool success = true; 66 bool success = true;
67 FileEnumerator::FileType traverse_type = 67 FileEnumerator::FileType traverse_type =
68 static_cast<FileEnumerator::FileType>(FileEnumerator::FILES | 68 static_cast<FileEnumerator::FileType>(FileEnumerator::FILES |
69 FileEnumerator::SHOW_SYM_LINKS | FileEnumerator::DIRECTORIES); 69 FileEnumerator::SHOW_SYM_LINKS | FileEnumerator::DIRECTORIES);
70 FileEnumerator traversal(source_dir, true, traverse_type); 70 FileEnumerator traversal(source_dir, true, traverse_type);
71 71
72 // dest_dir may not exist yet, start the loop with dest_dir 72 // dest_dir may not exist yet, start the loop with dest_dir
73 FileEnumerator::FindInfo info; 73 FileEnumerator::FindInfo info;
74 FilePath current = source_dir; 74 FilePath current = source_dir;
75 if (stat(source_dir.value().c_str(), &info.stat) < 0) { 75 if (stat(source_dir.value().c_str(), &info.stat) < 0) {
76 LOG(ERROR) << "CopyRecursiveDirNoCache() couldn't stat source directory: " 76 DLOG(ERROR) << "CopyRecursiveDirNoCache() couldn't stat source directory: "
77 << source_dir.value() << " errno = " << errno; 77 << source_dir.value() << " errno = " << errno;
78 success = false; 78 success = false;
79 } 79 }
80 80
81 while (success && !current.empty()) { 81 while (success && !current.empty()) {
82 // |current| is the source path, including source_dir, so paste 82 // |current| is the source path, including source_dir, so paste
83 // the suffix after source_dir onto dest_dir to create the target_path. 83 // the suffix after source_dir onto dest_dir to create the target_path.
84 std::string suffix(&current.value().c_str()[source_dir.value().size()]); 84 std::string suffix(&current.value().c_str()[source_dir.value().size()]);
85 // Strip the leading '/' (if any). 85 // Strip the leading '/' (if any).
86 if (!suffix.empty()) { 86 if (!suffix.empty()) {
87 DCHECK_EQ('/', suffix[0]); 87 DCHECK_EQ('/', suffix[0]);
88 suffix.erase(0, 1); 88 suffix.erase(0, 1);
89 } 89 }
90 const FilePath target_path = dest_dir.Append(suffix); 90 const FilePath target_path = dest_dir.Append(suffix);
91 91
92 if (S_ISDIR(info.stat.st_mode)) { 92 if (S_ISDIR(info.stat.st_mode)) {
93 if (mkdir(target_path.value().c_str(), info.stat.st_mode & 01777) != 0 && 93 if (mkdir(target_path.value().c_str(), info.stat.st_mode & 01777) != 0 &&
94 errno != EEXIST) { 94 errno != EEXIST) {
95 LOG(ERROR) << "CopyRecursiveDirNoCache() couldn't create directory: " << 95 DLOG(ERROR) << "CopyRecursiveDirNoCache() couldn't create directory: "
96 target_path.value() << " errno = " << errno; 96 << target_path.value() << " errno = " << errno;
97 success = false; 97 success = false;
98 } 98 }
99 } else if (S_ISREG(info.stat.st_mode)) { 99 } else if (S_ISREG(info.stat.st_mode)) {
100 if (CopyFile(current, target_path)) { 100 if (CopyFile(current, target_path)) {
101 success = EvictFileFromSystemCache(target_path); 101 success = EvictFileFromSystemCache(target_path);
102 DCHECK(success); 102 DCHECK(success);
103 } else { 103 } else {
104 LOG(ERROR) << "CopyRecursiveDirNoCache() couldn't create file: " << 104 DLOG(ERROR) << "CopyRecursiveDirNoCache() couldn't create file: "
105 target_path.value(); 105 << target_path.value();
106 success = false; 106 success = false;
107 } 107 }
108 } else { 108 } else {
109 LOG(WARNING) << "CopyRecursiveDirNoCache() skipping non-regular file: " << 109 DLOG(WARNING) << "CopyRecursiveDirNoCache() skipping non-regular file: "
110 current.value(); 110 << current.value();
111 } 111 }
112 112
113 current = traversal.Next(); 113 current = traversal.Next();
114 traversal.GetFindInfo(&info); 114 traversal.GetFindInfo(&info);
115 } 115 }
116 116
117 return success; 117 return success;
118 } 118 }
119 119
120 #if !defined(OS_LINUX) && !defined(OS_MACOSX) 120 #if !defined(OS_LINUX) && !defined(OS_MACOSX)
(...skipping 13 matching lines...) Expand all
134 134
135 bool MakeFileUnreadable(const FilePath& path) { 135 bool MakeFileUnreadable(const FilePath& path) {
136 return DenyFilePermission(path, S_IRUSR | S_IRGRP | S_IROTH); 136 return DenyFilePermission(path, S_IRUSR | S_IRGRP | S_IROTH);
137 } 137 }
138 138
139 bool MakeFileUnwritable(const FilePath& path) { 139 bool MakeFileUnwritable(const FilePath& path) {
140 return DenyFilePermission(path, S_IWUSR | S_IWGRP | S_IWOTH); 140 return DenyFilePermission(path, S_IWUSR | S_IWGRP | S_IWOTH);
141 } 141 }
142 142
143 } // namespace file_util 143 } // namespace file_util
OLDNEW
« no previous file with comments | « base/test/test_file_util_mac.cc ('k') | base/threading/non_thread_safe_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698