mirror of https://github.com/vitalif/grive2
added Chmod for files
parent
428afa6538
commit
a49794897a
|
@ -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() ;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#include <boost/exception/errinfo_file_open_mode.hpp>
|
||||
#include <boost/exception/info.hpp>
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
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
|
||||
|
|
|
@ -48,6 +48,8 @@ public :
|
|||
int Seek( long offset, int whence ) ;
|
||||
long Tell() const ;
|
||||
|
||||
void Chmod( int mode ) ;
|
||||
|
||||
private :
|
||||
std::FILE *m_file ;
|
||||
} ;
|
||||
|
|
Loading…
Reference in New Issue