19 #include <sys/types.h>
27 using namespace DD4hep;
31 class MyTFile :
public TFile {
37 virtual Int_t SysWrite(Int_t fd,
const void* buf, Int_t len) {
return TFile::SysWrite(fd, buf, len); }
39 virtual Int_t SysRead(Int_t fd,
void* buf, Int_t len) {
return TFile::SysRead(fd,buf,len); }
41 virtual Long64_t SysSeek(Int_t fd, Long64_t off, Int_t way) {
return TFile::SysSeek(fd, off, way); }
49 if ( m_handle ) ::close(m_handle);
50 m_handle = ::open(path,mode);
55 : m_handle(fd), m_flag(flags) { }
63 { return ::read(m_handle,s,n); }
67 { return ::write(m_handle,s,n); }
71 { return ::lseek(m_handle,off,way); }
75 if ( m_handle ) ::close(m_handle);
87 if ( mode&BOOST_IOS::out )
88 m_handle = TFile::Open(p.c_str(),
"RECREATE",
"ROOT");
90 m_handle = TFile::Open(p.c_str());
91 if ( m_handle->IsZombie() ) {
97 #define _p(x) (reinterpret_cast<MyTFile*>(x))
101 : m_handle(fd), m_flag(flags) { }
110 Long64_t nb1 = m_handle->GetBytesRead();
111 Bool_t res =
_p(m_handle)->ReadBuffer(s,nb1,n);
113 Long64_t nb2 = m_handle->GetBytesRead();
122 {
return m_handle ?
_p(m_handle)->SysWrite(m_handle->GetFd(),
s,n) : -1; }
126 {
return m_handle ?
_p(m_handle)->SysSeek(m_handle->GetFd(),off,way) : -1; }
130 {
if ( m_handle ) { m_handle->Close();
delete m_handle; m_handle=0; } }
std::streampos seek(stream_offset off, BOOST_IOS::seekdir way)
boost::iostreams::stream_offset stream_offset
std::streamsize read(char_type *s, std::streamsize n)
std::streamsize write(const char_type *s, std::streamsize n)
void open(handle_type fd, dd4hep_file_flags flags)