List of all members.
Detailed Description
Definition at line 29 of file file.
Constructor & Destructor Documentation
inlib::rroot::file::file |
( |
std::ostream & |
a_out, |
|
|
const std::string & |
a_path, |
|
|
bool |
a_verbose = false |
|
) |
| [inline] |
Definition at line 99 of file file.
:m_out(a_out)
,m_path(a_path)
,m_verbose(a_verbose)
,m_file(not_open())
,m_bytes_read(0)
,m_root_directory(*this)
,m_version(0)
,m_BEGIN(0)
,m_END(0)
,m_seek_free(0)
,m_nbytes_free(0)
,m_nbytes_name(0)
{
#ifdef INLIB_MEM
mem::increment(s_class().c_str());
#endif
m_file = _open(a_path.c_str(),
#ifdef WIN32
O_RDONLY | O_BINARY,S_IREAD | S_IWRITE
#else
O_RDONLY,0644
#endif
);
if(m_file==not_open()) {
m_out << "inlib::rroot::file::file :"
<< " can't open " << sout(a_path) << "."
<< std::endl;
return;
}
initialize();
}
virtual inlib::rroot::file::~file |
( |
| ) |
[inline, virtual] |
Definition at line 135 of file file.
{
close();
#ifdef INLIB_MEM
mem::decrement(s_class().c_str());
#endif
}
inlib::rroot::file::file |
( |
const file & |
a_from | ) |
[inline, protected] |
Definition at line 142 of file file.
Member Function Documentation
static int inlib::rroot::file::_open |
( |
const char * |
a_name, |
|
|
int |
a_flags, |
|
|
uint32 |
a_mode |
|
) |
| [inline, static, protected] |
Definition at line 176 of file file.
{
#if defined(__linux__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 2)
return ::open64(a_name,a_flags,a_mode);
#else
return ::open(a_name,a_flags,a_mode);
#endif
}
bool inlib::rroot::file::add_unziper |
( |
char |
a_key, |
|
|
unzip_func |
a_func |
|
) |
| [inline] |
Definition at line 164 of file file.
{
std::map<char,unzip_func>::iterator it = m_unzipers.find(a_key);
if(it!=m_unzipers.end()) {
return false;
} else {
m_unzipers[a_key] = a_func;
return true;
}
}
virtual bool inlib::rroot::file::byte_swap |
( |
| ) |
const [inline, virtual] |
void inlib::rroot::file::close |
( |
| ) |
[inline] |
Definition at line 155 of file file.
directory& inlib::rroot::file::dir |
( |
| ) |
[inline] |
Definition at line 161 of file file.
const directory& inlib::rroot::file::dir |
( |
| ) |
const [inline] |
Definition at line 162 of file file.
int inlib::rroot::file::error_number |
( |
| ) |
[inline, protected] |
Definition at line 390 of file file.
bool inlib::rroot::file::initialize |
( |
| ) |
[inline, protected] |
Definition at line 186 of file file.
{
if(!read_header()) {
m_out << "inlib::rroot::file::initialize :"
<< " can't read header."
<< std::endl;
return false;
}
uint32 nbytes = m_nbytes_name + m_root_directory.record_size(m_version);
char* header = new char[nbytes];
char* buffer = header;
if(!set_pos(m_BEGIN)) {
m_out << "inlib::rroot::file::initialize :"
<< " can't set position."
<< std::endl;
delete [] header;
return false;
}
if(!read_buffer(buffer,nbytes)) {
m_out << "inlib::rroot::file::initialize :"
<< " can't read buffer."
<< std::endl;
delete [] header;
return false;
}
buffer = header+m_nbytes_name;
const char* eob = header+nbytes;
if(!m_root_directory.from_buffer(eob,buffer)) {
m_out << "inlib::rroot::file::initialize :"
<< " can't read buffer (2)."
<< std::endl;
delete [] header;
return false;
}
uint32 nk =
sizeof(int) +
sizeof(short) +
2*sizeof(int) +
2*sizeof(short) +
2*sizeof(seek32);
buffer = header+nk;
std::string cname;
rbuf rb(m_out,byte_swap(),eob,buffer);
if(!rb.read(cname)) {
m_out << "inlib::rroot::file::initialize :"
<< " can't read buffer (3)."
<< std::endl;
delete [] header;
return false;
}
if(cname!="TFile") {
m_out << "inlib::rroot::file::initialize : TFile expected." << std::endl;
delete [] header;
return false;
}
if(m_verbose) {
m_out << "inlib::rroot::file::initialize :"
<< " " << sout("TFile") << " found."
<< std::endl;
}
if(!rb.read(cname)) {
m_out << "inlib::rroot::file::initialize :"
<< " can't read buffer (4)."
<< std::endl;
delete [] header;
return false;
}
if(m_verbose) {
m_out << "inlib::rroot::file::initialize :"
<< " found file name " << sout(cname)
<< std::endl;
}
if(!rb.read(m_title)) {
m_out << "inlib::rroot::file::initialize :"
<< " can't read buffer (5)."
<< std::endl;
delete [] header;
return false;
}
delete [] header;
if(m_verbose) {
m_out << "inlib::rroot::file::initialize :"
<< " found title " << sout(m_title)
<< std::endl;
}
uint32 dirNbytesName = m_root_directory.nbytes_name();
if (dirNbytesName < 10 || dirNbytesName > 1000) {
m_out << "inlib::rroot::file::initialize :"
<< " can't read directory info."
<< std::endl;
return false;
}
if(m_root_directory.seek_keys() > m_BEGIN) {
uint32 n;
if(!m_root_directory.read_keys(n)) {
m_out << "inlib::rroot::file::initialize :"
<< " can't read keys."
<< std::endl;
return false;
}
} else {
m_out << "inlib::rroot::file::initialize :"
<< " file " << sout(m_path)
<< " probably not closed."
<< std::endl;
return false;
}
return true;
}
file& inlib::rroot::file::operator= |
( |
const file & |
| ) |
[inline, protected] |
Definition at line 151 of file file.
virtual std::ostream& inlib::rroot::file::out |
( |
| ) |
[inline, virtual] |
virtual bool inlib::rroot::file::read_buffer |
( |
char * |
a_buffer, |
|
|
uint32 |
a_length |
|
) |
| [inline, virtual] |
Implements inlib::rroot::ifile.
Definition at line 65 of file file.
{
ssize_t siz;
while ((siz = ::read(m_file,a_buffer,a_length)) < 0 &&
error_number() == EINTR) reset_error_number();
if (siz < 0) {
m_out << "inlib::rroot::file::read_buffer :"
<< " error reading from file " << sout(m_path) << "."
<< std::endl;
return false;
}
if (siz != ssize_t(a_length)) {
m_out << "inlib::rroot::file::read_buffer :"
<< " error reading all requested bytes from file "
<< sout(m_path) << ", got " << long2s(siz)
<< " of " << a_length
<< std::endl;
return false;
}
m_bytes_read += siz;
return true;
}
bool inlib::rroot::file::read_header |
( |
| ) |
[inline, protected] |
Definition at line 314 of file file.
{
static const uint32 kBegin = 64;
char header[kBegin];
if(!set_pos()) return false;
if(!read_buffer(header,kBegin)) return false;
if(::strncmp(header, "root", 4)) {
m_out << "inlib::rroot::file::read_header :"
<< " " << sout(m_path) << " not a ROOT file."
<< std::endl;
return false;
}
if(m_verbose) {
m_out << "inlib::rroot::file::read_header :"
<< " file signature is " << sout("root")
<< std::endl;
}
char* buffer = header + 4;
const char* eob = header + kBegin;
rbuf rb(m_out,byte_swap(),eob,buffer);
{int v;
if(!rb.read(v)) return false;
m_version = v;}
{seek32 i;
if(!rb.read(i)) return false;
m_BEGIN = i;}
if(m_version>1000000) {
if(!rb.read(m_END)) return false;
if(!rb.read(m_seek_free)) return false;
} else {
{seek32 i;
if(!rb.read(i)) return false;
m_END = i;}
{seek32 i;
if(!rb.read(i)) return false;
m_seek_free = i;}
}
if(m_verbose) {
m_out << "inlib::rroot::file::read_header :"
<< " begin " << m_BEGIN
<< " end " << m_END
<< std::endl;
}
{int v;
if(!rb.read(v)) return false;
m_nbytes_free = v;}
int nfree = 0;
if(!rb.read(nfree)) return false;
{int v;
if(!rb.read(v)) return false;
m_nbytes_name = v;}
return true;
}
void inlib::rroot::file::reset_error_number |
( |
| ) |
[inline, protected] |
Definition at line 391 of file file.
static const std::string& inlib::rroot::file::s_class |
( |
| ) |
[inline, static, protected] |
Definition at line 381 of file file.
{
static const std::string s_v("inlib::rroot::file");
return s_v;
}
virtual bool inlib::rroot::file::set_pos |
( |
seek |
a_offset = 0 , |
|
|
from |
a_from = begin |
|
) |
| [inline, virtual] |
Implements inlib::rroot::ifile.
Definition at line 36 of file file.
{
int whence = 0;
switch(a_from) {
case begin:
whence = SEEK_SET;
break;
case current:
whence = SEEK_CUR;
break;
case end:
whence = SEEK_END;
break;
}
#if defined(__linux__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 2)
if (::lseek64(m_file, a_offset, whence) < 0) {
#elif defined(WIN32)
if (::_lseeki64(m_file, a_offset, whence) < 0) {
#else
if (::lseek(m_file, a_offset, whence) < 0) {
#endif
m_out << "inlib::rroot::file::set_pos :"
<< " cannot set position " << a_offset
<< " in file " << sout(m_path) << "."
<< std::endl;
return false;
}
return true;
}
static std::string inlib::rroot::file::sout |
( |
const std::string & |
a_string | ) |
[inline, static, protected] |
Definition at line 183 of file file.
{
return std::string("\"")+a_string+"\"";
}
virtual bool inlib::rroot::file::unziper |
( |
char |
a_key, |
|
|
unzip_func & |
a_func |
|
) |
| [inline, virtual] |
Implements inlib::rroot::ifile.
Definition at line 88 of file file.
{
std::map<char,unzip_func>::iterator it = m_unzipers.find(a_key);
if(it==m_unzipers.end()) {
a_func = 0;
return false;
}
a_func = (*it).second;
return true;
}
virtual bool inlib::rroot::file::verbose |
( |
| ) |
const [inline, virtual] |
uint32 inlib::rroot::file::version |
( |
| ) |
const [inline] |
Definition at line 153 of file file.
Member Data Documentation
Definition at line 405 of file file.
Definition at line 399 of file file.
Definition at line 406 of file file.
Definition at line 398 of file file.
Definition at line 408 of file file.
Definition at line 410 of file file.
Definition at line 395 of file file.
Definition at line 396 of file file.
Definition at line 400 of file file.
Definition at line 407 of file file.
Definition at line 402 of file file.
Definition at line 401 of file file.
Definition at line 397 of file file.
Definition at line 404 of file file.
The documentation for this class was generated from the following file:
- /Users/barrand/private/dev/softinex/old/inexlib-1.2/inlib/inlib/rroot/file