diff --git a/grive/src/Config.cc b/grive/src/Config.cc index a740a5d..b5fbbef 100644 --- a/grive/src/Config.cc +++ b/grive/src/Config.cc @@ -56,10 +56,6 @@ Json Config::Read( const std::string& filename ) } catch ( Exception& e ) { -// throw Error() -// << File( filename ) -// << expt::ErrMsg("Cannot open config file ") -// << expt::Nested(e) ; return Json() ; } } diff --git a/libgrive/src/util/OS.cc b/libgrive/src/util/OS.cc index 77077ab..31cc959 100644 --- a/libgrive/src/util/OS.cc +++ b/libgrive/src/util/OS.cc @@ -73,7 +73,12 @@ void SetFileTime( const std::string& filename, const DateTime& t ) { struct timeval tvp[2] = { t.Tv(), t.Tv() } ; if ( ::utimes( filename.c_str(), tvp ) != 0 ) - throw expt::ErrMsg( "cannot set file time" ) ; + BOOST_THROW_EXCEPTION( + Error() + << boost::errinfo_api_function("utimes") + << boost::errinfo_errno(errno) + << boost::errinfo_file_name(filename) + ) ; } } } // end of namespaces diff --git a/libgrive/src/util/StdioFile.cc b/libgrive/src/util/StdioFile.cc index adca10e..a15bb91 100644 --- a/libgrive/src/util/StdioFile.cc +++ b/libgrive/src/util/StdioFile.cc @@ -30,6 +30,8 @@ #include #include +#include + namespace gr { StdioFile::StdioFile( const std::string& filename, const char *mode ) : m_file( 0 ) @@ -110,4 +112,28 @@ long StdioFile::Tell() const return std::ftell( m_file ) ; } +void StdioFile::Chmod( int mode ) +{ + assert( m_file != 0 ) ; + + int fd = ::fileno(m_file) ; + if ( fd == -1 ) + { + BOOST_THROW_EXCEPTION( + Error() + << boost::errinfo_api_function("fileno") + << boost::errinfo_errno(errno) + ) ; + } + + if ( ::fchmod( fd, mode ) != 0 ) + { + BOOST_THROW_EXCEPTION( + Error() + << boost::errinfo_api_function("fchmod") + << boost::errinfo_errno(errno) + ) ; + } +} + } // end of namespace diff --git a/libgrive/src/util/StdioFile.hh b/libgrive/src/util/StdioFile.hh index d6ea1d2..002fd53 100644 --- a/libgrive/src/util/StdioFile.hh +++ b/libgrive/src/util/StdioFile.hh @@ -48,6 +48,8 @@ public : int Seek( long offset, int whence ) ; long Tell() const ; + void Chmod( int mode ) ; + private : std::FILE *m_file ; } ;