21 #include <sys/types.h>
28 class MyTFile :
public TFile {
34 virtual Int_t SysWrite(Int_t fd,
const void* buf, Int_t len)
override {
return TFile::SysWrite(fd, buf, len); }
36 virtual Int_t SysRead(Int_t fd,
void* buf, Int_t len)
override {
return TFile::SysRead(fd,buf,len); }
38 virtual Long64_t SysSeek(Int_t fd, Long64_t off, Int_t way)
override {
return TFile::SysSeek(fd, off, way); }
46 if ( m_handle ) ::close(m_handle);
47 m_handle = ::open(path,mode);
52 : m_handle(fd), m_flag(flags) { }
60 { return ::read(m_handle,s,n); }
64 { return ::write(m_handle,s,n); }
68 { return ::lseek(m_handle,off,way); }
72 if ( m_handle ) ::close(m_handle);
84 if ( mode&BOOST_IOS::out )
85 m_handle = TFile::Open(p.c_str(),
"RECREATE",
"ROOT");
87 m_handle = TFile::Open(p.c_str());
88 if ( m_handle->IsZombie() ) {
94 #define _p(x) (reinterpret_cast<MyTFile*>(x))
98 : m_handle(fd), m_flag(flags) { }
107 Long64_t nb1 = m_handle->GetBytesRead();
108 Bool_t res =
_p(m_handle)->ReadBuffer(s,nb1,n);
110 Long64_t nb2 = m_handle->GetBytesRead();
119 {
return m_handle ?
_p(m_handle)->SysWrite(m_handle->GetFd(),s,n) : -1; }
123 {
return m_handle ?
_p(m_handle)->SysSeek(m_handle->GetFd(),off,way) : -1; }
127 {
if ( m_handle ) { m_handle->Close();
delete m_handle; m_handle=0; } }