summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-03 22:39:34 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-03 22:39:34 +0000
commit2237f5d79d68d3245f22bedad3f2a757707fdcd3 (patch)
treed93b2c7928584d9867d70424349f55e199aea5bd /base
parent7d8bbd0bd7452ef7ae9157688210030554517629 (diff)
downloadchromium_src-2237f5d79d68d3245f22bedad3f2a757707fdcd3.zip
chromium_src-2237f5d79d68d3245f22bedad3f2a757707fdcd3.tar.gz
chromium_src-2237f5d79d68d3245f22bedad3f2a757707fdcd3.tar.bz2
posix: don't complain when stat() fails with ENOENT
It's not useful to warn the user about broken symlinks when iterating a directory tree. Review URL: http://codereview.chromium.org/197017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25392 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/file_util_posix.cc22
1 files changed, 13 insertions, 9 deletions
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc
index b02df8e..5bc3306 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -645,18 +645,22 @@ bool FileEnumerator::ReadDirectory(std::vector<DirectoryEntryInfo>* entries,
struct dirent* dent;
while (readdir_r(dir, &dent_buf, &dent) == 0 && dent) {
DirectoryEntryInfo info;
- FilePath full_name;
- int stat_value;
-
info.filename = FilePath(dent->d_name);
- full_name = source.Append(dent->d_name);
+
+ FilePath full_name = source.Append(dent->d_name);
+ int ret;
if (show_links)
- stat_value = lstat(full_name.value().c_str(), &info.stat);
+ ret = lstat(full_name.value().c_str(), &info.stat);
else
- stat_value = stat(full_name.value().c_str(), &info.stat);
- if (stat_value < 0) {
- LOG(ERROR) << "Couldn't stat file: " <<
- source.Append(dent->d_name).value().c_str() << " errno = " << errno;
+ ret = stat(full_name.value().c_str(), &info.stat);
+ if (ret < 0) {
+ // Print the stat() error message unless it was ENOENT and we're
+ // following symlinks.
+ if (!(ret == ENOENT && !show_links)) {
+ LOG(ERROR) << "Couldn't stat "
+ << source.Append(dent->d_name).value() << ": "
+ << strerror(errno);
+ }
memset(&info.stat, 0, sizeof(info.stat));
}
entries->push_back(info);