Go to the documentation of this file.
4 #ifndef tools_rroot_file
5 #define tools_rroot_file
11 #include "../platform"
32 file& get_me() {
return *
this;}
33 static int not_open() {
return -1;}
36 static const std::string s_v(
"tools::rroot::file");
44 virtual std::ostream&
out()
const {
return m_out;}
61 #if defined(__linux__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 2)
62 if (::lseek64(
m_file, a_offset, whence) < 0) {
63 #elif defined(_MSC_VER)
64 if (::_lseeki64(
m_file, a_offset, whence) < 0) {
66 if (::lseek(
m_file, a_offset, whence) < 0) {
68 m_out <<
"tools::rroot::file::set_pos :"
69 <<
" cannot set position " << a_offset
83 while ((siz = ::
read(
m_file,a_buffer,a_length)) < 0 &&
86 m_out <<
"tools::rroot::file::read_buffer :"
87 <<
" error reading from file " <<
sout(
m_path) <<
"."
91 if (siz != ssize_t(a_length)) {
92 m_out <<
"tools::rroot::file::read_buffer :"
93 <<
" error reading all requested bytes from file "
103 std::map<char,decompress_func>::const_iterator it =
m_unzipers.find(a_key);
108 a_func = (*it).second;
115 file(std::ostream& a_out,
const std::string& a_path,
bool a_verbose =
false)
136 mem::increment(
s_class().c_str());
141 O_RDONLY | O_BINARY,S_IREAD | S_IWRITE
147 m_out <<
"tools::rroot::file::file :"
148 <<
" can't open " <<
sout(a_path) <<
"."
157 mem::decrement(
s_class().c_str());
170 mem::increment(
s_class().c_str());
178 return (
m_file==not_open()?
false:
true);
191 std::map<char,decompress_func>::const_iterator it =
m_unzipers.find(a_key);
206 if(!info)
return false;
217 if(info->
name()==a_class)
return info;
225 #if defined(__linux__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 2)
226 return ::open64(a_name,a_flags,a_mode);
228 return ::open(a_name,a_flags,a_mode);
231 static std::string
sout(
const std::string& a_string) {
return "\""+a_string+
"\"";}
234 m_out <<
"tools::rroot::file::initialize :"
235 <<
" can't read header."
257 char* header =
new char[nbytes];
260 m_out <<
"tools::rroot::file::initialize :"
261 <<
" can't set position."
267 m_out <<
"tools::rroot::file::initialize :"
268 <<
" can't read buffer."
274 const char* eob = header+nbytes;
276 m_out <<
"tools::rroot::file::initialize :"
277 <<
" can't read buffer (2)."
293 if(!rb.
read(cname)) {
294 m_out <<
"tools::rroot::file::initialize :"
295 <<
" can't read buffer (3)."
301 m_out <<
"tools::rroot::file::initialize : TFile expected." << std::endl;
306 m_out <<
"tools::rroot::file::initialize :"
307 <<
" " <<
sout(
"TFile") <<
" found."
310 if(!rb.
read(cname)) {
311 m_out <<
"tools::rroot::file::initialize :"
312 <<
" can't read buffer (4)."
318 m_out <<
"tools::rroot::file::initialize :"
319 <<
" found file name " <<
sout(cname)
323 m_out <<
"tools::rroot::file::initialize :"
324 <<
" can't read buffer (5)."
331 m_out <<
"tools::rroot::file::initialize :"
336 if (dirNbytesName < 10 || dirNbytesName > 1000) {
337 m_out <<
"tools::rroot::file::initialize :"
338 <<
" can't read directory info."
346 m_out <<
"tools::rroot::file::initialize :"
347 <<
" can't read keys."
352 m_out <<
"tools::rroot::file::initialize :"
354 <<
" probably not closed."
362 m_out <<
"tools::rroot::file::initialize :"
363 <<
" read_streamer_infos_key() failed."
368 m_out <<
"tools::rroot::file::initialize :"
370 <<
" probably not closed."
378 static const uint32 kBegin = 64;
383 if(::strncmp(header,
"root", 4)) {
384 m_out <<
"tools::rroot::file::read_header :"
385 <<
" " <<
sout(
m_path) <<
" not a file at the CERN-ROOT format."
390 m_out <<
"tools::rroot::file::read_header :"
391 <<
" file signature is " <<
sout(
"root")
394 char*
buffer = header + 4;
395 const char* eob = header + kBegin;
398 if(!rb.
read(v))
return false;
401 if(!rb.
read(i))
return false;
408 if(!rb.
read(i))
return false;
411 if(!rb.
read(i))
return false;
415 m_out <<
"tools::rroot::file::read_header :"
421 if(!rb.
read(v))
return false;
424 if(!rb.
read(nfree))
return false;
426 if(!rb.
read(v))
return false;
430 if(!rb.
read(fUnits))
return false;}
432 if(!rb.
read(fCompress))
return false;}
437 if(!rb.
read(i))
return false;
466 m_out <<
"tools::rroot::file::read_streamer_infos_data : key not a TList." << std::endl;
472 m_out <<
"tools::rroot::file::read_streamer_infos :"
473 <<
" can't get data buffer of " << k.
object_name() <<
"."
481 #if defined(__sun) && !defined(__linux__) && (__SUNPRO_CC > 0x420)
#define tools_vforcit(a__T, a__v, a__it)