Re: How to know if a file is finished writing or not ?

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Jul 06 1998 - 13:18:00 MEST


Wei Xie wrote:
> 
> Dear Rooters'
> 
> Assume I have a data file which is written on a disk, and deleted
> automatically after 5 minutes, and then written on the disk again.
> This loop will continues as long as necessary.
> 
> If I want to read the file in ROOT every now and then,
> the old file may have  already been deleted and new file is still being
> written and not finished yet.  So if I read it at this moment, some
> errors will occur. Is there any method in ROOT that can distinguish if
> a file is finished written or not ?
> 

You can test if at least one object has been written to the file
with:

  TFile *myfile;
  myfile = new TFile("myfile.root");
  if (myfile.GetSeekKeys() <= 64) {
     printf("file probably not yet closed\n");
     // wait and try again
  }

Note that you will get a Warning message from Root every time
you try to connect a file not yet closed.

Rene Brun



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:34 MET