Skip to content

Commit

Permalink
rutil: add FileSystem::Exception, check stat() return value
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.resiprocate.org/rep/resiprocate/main@10371 ddefafc4-47db-0310-ae44-fa13212b10f2
  • Loading branch information
dpocock committed Aug 15, 2013
1 parent 67cc3cb commit 30506ff
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 4 additions & 1 deletion rutil/FileSystem.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ FileSystem::Directory::iterator::is_directory() const
return mDirent->d_type == DT_DIR;
#else
struct stat s;
stat(mDirent->d_name, &s);
if(stat(mDirent->d_name, &s) < 0)
{
throw Exception("stad() failed", __FILE__, __LINE__);
}
return S_ISDIR(s.st_mode);
#endif
}
Expand Down
13 changes: 13 additions & 0 deletions rutil/FileSystem.hxx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef RESIP_FileSystem_hxx
#define RESIP_FileSystem_hxx

#include "rutil/BaseException.hxx"
#include "rutil/Data.hxx"

#if !defined(WIN32)
Expand Down Expand Up @@ -30,6 +31,18 @@ namespace resip
class FileSystem
{
public:

class Exception : public BaseException
{
public:
Exception(const Data& msg,
const Data& file,
const int line)
: BaseException(msg, file, line) {}
protected:
virtual const char* name() const { return "ConfigParse::Exception"; }
};

class Directory
{
public:
Expand Down

0 comments on commit 30506ff

Please sign in to comment.