Re: [ROOT] open all data files

From: Valeri Fine (Faine) (fine@bnl.gov)
Date: Mon Nov 20 2000 - 22:42:29 MET


This can be useful as well:

http://root.cern.ch/root/htmldoc/TFileSet.html#TFileSet:description

 If you would follow the example below don't forget ending up with

          gSystem->FreeDirectory(dirp)

to avoid the memory leaks and some "problems"

                 Valery

----- Original Message ----- 
From: Valeriy Onuchin <onuchin@sirius.ihep.su>
To: Jan Malinowski <malinow@krysia.uni.lodz.pl>
Cc: <roottalk@cern.ch>
Subject: Re: [ROOT] open all data files


> Jan Malinowski wrote:
> 
> >
> >
> > Dear Rooters,
> >
> > While programing in C or C++ under Win95 or DOS
> > I open the files from directory with ' findfirst( .. ) ' and ' findnext(
> > .. ) ' functions.
> >
> >          struct ffblk fb;
> >          char WildCard[13] = "*.*";
> >          done = findfirst( WildCard, &fb, 0 );
> >          while ( !done ) {
> >                   fin = fopen( fb.ff_name, "rt" );
> > ..........
> >                   fclose( fin );
> >                   done = findnext( &fb );
> >          }
> >
> > This functions are located in "dir.h" file.
> > I have instaled ROOT under Win95. I cannot include "dir.h" file.
> > I have chacked: it is not in "./include/" directory.
> >
> > In what way can I do the same file opening in ROOT ?
> > Regards,
> >     Janek.
> 
>  Hi Janek,
> check this
> 
> file://___________________________________________________________________
> void ls(const char* inDir, const char * ext=".h")
> {
>    // Lists all files in the inDir with extension ext
> 
>    char* dir = gSystem->ExpandPathName(inDir);
>    void* dirp = gSystem->OpenDirectory(dir);
> 
>    if( !dirp ) {
>       printf("Failed to open directory: %d\n",inDir);
>       return;
>    }
> 
>    const char* entry;
>    const char* filename;
>    TString str;
> 
>    while( entry=gSystem->GetDirEntry(dirp) ) {
>       str = entry;
> 
>       if( str.EndsWith(ext) ) {
>          filename = gSystem->ConcatFileName(dir,entry);
>          printf("File %s\n",filename);
>       }
>    }
> }
> 
> to print out all header file in $ROOTSYS/include try
> 
> ls("$(ROOTSYS)/include",".h")
> 
> Regards.    Valeriy
> 
> 



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:37 MET