Hi Mark,
yes you can do:
if (file->IsWritable()) ...
TFile derives from TDirectory. Look at TDirectory::IsWritable.
A Root file in general may contain several sub directories.
You can test the write access for the whole file or one of its subdirs.
Rene Brun
Mark James Boland wrote:
>
> Hello roottalk,
>
> Could some one help me with a question on checking the status of a
> file. Is there a way using a ROOT macro to test if a file can be written
> to? Eg. in C I would do the check
>
> FILE *fPtr;
> if((fPtr = fopen("file.dat","w")) == NULL) printf("can't open file.dat");
>
> I can't seem to find a function with a return value that I can test in
> the same way as the fopen function. Is there a "file->CanWriteTo()" type
> of check?
>
> I am using ROOT 2.22/09 on Linux.
>
> Regards,
> Mark
> ___________________________________________________________________
> Mark Boland markjb@physics.unimelb.edu.au
> School of Physics PhD Student
> The University of Melbourne Photonuclear Group
> Fax: +61 3 9347 4783 Ph: +61 3 9344 5426
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:17 MET