[ROOT] Iterating through a file: bug?

From: Mike Kordosky (kordosky@mail.hep.utexas.edu)
Date: Tue May 14 2002 - 23:07:53 MEST


Hi,

Is this a bug?:

    const string inname(argv[1]);
    const string outname(argv[2]);

    TFile infile(inname.c_str(), "read");
    TFile outfile(outname.c_str(), "recreate");
//    infile.cd();
    TIter it(infile.GetListOfKeys());

    while(TKey* key = static_cast<TKey*>(it())){
	TObject* obj = key->ReadObj();
	.
	.
	.

I get errors of the form:

Error in <TFile::ReadBuffer>: error reading all requested bytes from file
junk.root, got 0 of 318
R__unzip: error in header

I suppose that this is because junk.root corresponds to "outfile" above
and it has just been created.  But why is it reading from the "outfile"
rather than the "infile"?  Is this the desired behavior and if so, why?

Uncommenting the line infile.cd() fixes the problem.

I use root 3.02/07 with gcc2.95.3 on a linux pc.

Mike Kordosky

-- 
Graduate Research Assistant  // High Energy Physics Lab
kordosky@hep.utexas.edu     // University of Texas at Austin
kordosky@fnal.gov	   //
ph: (512) 471-8426 (RLM Lab, Office)
    (512) 475-8673 (ENS Lab)



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:53 MET