Re: [ROOT] open all data files

From: Valeriy Onuchin (onuchin@sirius.ihep.su)
Date: Mon Nov 20 2000 - 18:37:46 MET


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

//___________________________________________________________________
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