Skip to content

Commit

Permalink
check for file existence before probing file info directly
Browse files Browse the repository at this point in the history
  • Loading branch information
jjallaire committed Jul 7, 2011
1 parent f118e60 commit b04bb0e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/cpp/core/FilePath.cpp
Expand Up @@ -259,7 +259,10 @@ uintmax_t FilePath::size() const
{
try
{
return boost::filesystem::file_size(pImpl_->path) ;
if (!exists())
return 0;
else
return boost::filesystem::file_size(pImpl_->path) ;
}
catch(const boost::filesystem::filesystem_error& e)
{
Expand Down Expand Up @@ -400,7 +403,10 @@ std::time_t FilePath::lastWriteTime() const
{
try
{
return boost::filesystem::last_write_time(pImpl_->path) ;
if (!exists())
return 0;
else
return boost::filesystem::last_write_time(pImpl_->path) ;
}
catch(const boost::filesystem::filesystem_error& e)
{
Expand Down Expand Up @@ -541,7 +547,10 @@ bool FilePath::isDirectory() const
{
try
{
return boost::filesystem::is_directory(pImpl_->path) ;
if (!exists())
return false;
else
return boost::filesystem::is_directory(pImpl_->path) ;
}
catch(const boost::filesystem::filesystem_error& e)
{
Expand Down

0 comments on commit b04bb0e

Please sign in to comment.