{
   gROOT->Reset();
   
   char base_dir[]="$(ROOTSYS)"; // directory to get listing; here $ROOTSYS
   TString basename("*");        // file name pattern; here: all files
   const char *file;
   
   // expanding environment variable in the directory name, if any
   void *dir = gSystem->OpenDirectory(gSystem->ExpandPathName(base_dir));

   if (dir) {
      TRegexp re(basename,kTRUE);
      while ((file = gSystem->GetDirEntry(dir))) {
         // skipping "." and ".." to avoid infinite loop
         if (!strcmp(file,".") || !strcmp(file,"..")) continue;
         TString s = file;
	 // comparing the file name with pattern
         if ( (basename!=file) && s.Index(re) == kNPOS) continue;
	 // printing out the file name
	 cout << file << endl;
	 // How to find out whether <file> is an ordinary file or directory???
      }
   }
}


