[POSIX] stop logging on ENOENT

This change stops IsRegularFile and IsDirectory from logging
an error in the instance that a file or directory cannot be found.

Change-Id: I9f3c409933245708db775f566a27f5e49b2c71f3
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1795924
Commit-Queue: Francois Rousseau <frousseau@google.com>
Reviewed-by: Scott Graham <scottmg@chromium.org>
This commit is contained in:
Alex Pankhurst 2019-09-10 10:16:01 -07:00 committed by Commit Bot
parent e97cf7b29c
commit 2bfd3c4edc
2 changed files with 8 additions and 4 deletions

View File

@ -73,7 +73,8 @@ bool MoveFileOrDirectory(const base::FilePath& source,
//! failure.
//!
//! On POSIX, this function returns `true` if \a path refers to a file that is
//! not a symbolic link, directory, or other kind of special file.
//! not a symbolic link, directory, or other kind of special file. If this
//! function fails because \a path does not exist, then no message is logged.
//!
//! On Windows, this function returns `true` if \a path refers to a file that
//! is not a symbolic link or directory.
@ -85,6 +86,9 @@ bool IsRegularFile(const base::FilePath& path);
//! \brief Determines if a path refers to a directory, logging a message on
//! failure.
//!
//! On POSIX, if this function fails because \a path does not exist, then no
//! message is logged.
//!
//! \param[in] path The path to check.
//! \param[in] allow_symlinks Whether to allow the final component in the path
//! to be a symbolic link to a directory.

View File

@ -76,7 +76,7 @@ bool MoveFileOrDirectory(const base::FilePath& source,
bool IsRegularFile(const base::FilePath& path) {
struct stat st;
if (lstat(path.value().c_str(), &st) != 0) {
PLOG(ERROR) << "stat " << path.value();
PLOG_IF(ERROR, errno != ENOENT) << "stat " << path.value();
return false;
}
return S_ISREG(st.st_mode);
@ -86,11 +86,11 @@ bool IsDirectory(const base::FilePath& path, bool allow_symlinks) {
struct stat st;
if (allow_symlinks) {
if (stat(path.value().c_str(), &st) != 0) {
PLOG(ERROR) << "stat " << path.value();
PLOG_IF(ERROR, errno != ENOENT) << "stat " << path.value();
return false;
}
} else if (lstat(path.value().c_str(), &st) != 0) {
PLOG(ERROR) << "lstat " << path.value();
PLOG_IF(ERROR, errno != ENOENT) << "lstat " << path.value();
return false;
}
return S_ISDIR(st.st_mode);