summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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);