diff --git a/util/file/filesystem.h b/util/file/filesystem.h index 27a4d1de..e12f1271 100644 --- a/util/file/filesystem.h +++ b/util/file/filesystem.h @@ -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. diff --git a/util/file/filesystem_posix.cc b/util/file/filesystem_posix.cc index b1f19f62..bb51a9c1 100644 --- a/util/file/filesystem_posix.cc +++ b/util/file/filesystem_posix.cc @@ -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);