From 2854eed1831bb05d3d8a9e7e7533b9af90419638 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Tue, 16 Mar 2010 08:39:45 +0000 Subject: [PATCH] Return false instead of throwing an exception if file does not exist in isDirectory(), isFile(), canRead() and canWrite(). --- src/platforms/posix/posixFile.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/platforms/posix/posixFile.cpp b/src/platforms/posix/posixFile.cpp index b814b758..ec529eb6 100644 --- a/src/platforms/posix/posixFile.cpp +++ b/src/platforms/posix/posixFile.cpp @@ -306,6 +306,9 @@ bool posixFile::isFile() const if (::stat(m_nativePath.c_str(), &buf) == -1) { + if (errno == ENOENT) + return false; + posixFileSystemFactory::reportError(m_path, errno); return false; } @@ -320,6 +323,9 @@ bool posixFile::isDirectory() const if (::stat(m_nativePath.c_str(), &buf) == -1) { + if (errno == ENOENT) + return false; + posixFileSystemFactory::reportError(m_path, errno); return false; } @@ -334,6 +340,9 @@ bool posixFile::canRead() const if (::stat(m_nativePath.c_str(), &buf) == -1) { + if (errno == ENOENT) + return false; + posixFileSystemFactory::reportError(m_path, errno); return false; } @@ -349,6 +358,9 @@ bool posixFile::canWrite() const if (::stat(m_nativePath.c_str(), &buf) == -1) { + if (errno == ENOENT) + return false; + posixFileSystemFactory::reportError(m_path, errno); return false; }