Re: Loop over the file directory tree (was no subject)

From: Valeri Fine (Faine) (fine@bnl.gov)
Date: Fri Mar 03 2000 - 17:35:33 MET


Hello Jens,
I am sorry I missed your question since it has no "Subj".

To use gSystem::GetDirEntry
one has to open that directory with

void *dirp = gSystem::OpenDirectory("path")

then you can read in loop that directory:

while(cont char *nextFileName= gSystem::GetDirEntry(dirp)) { < actions>}

and should close that directory just you decide you done:

 gSystem->FreeDirectory(dirp);

Very likely you will want to distinguish "files" and "directories"

gSystmem->GetPathInfo can help you (see:

http://root.cern.ch/root/html/TSystem.html#TSystem:GetPathInfo

           Valery

> Hello rooters of the world.
>
> I'm working on a macro to analyze several data files all being in the same
> directory. Btw. I'm using v2.23/12 on RH6.1. Now, I want to go through the
> files one by one. Therefore I wonder if there is a way in ROOT to be
> able to get hold of the names of files in a directory in succesive
> order.
> I tried both with both TSystem's (i.e. gSystem) and TUnixSystem's
> GetDirEntry(void *dirp), but now luck. What kind of pointers are allowed
> for 'dirp' in this function call?
> The description of TUnixSystem::GetDirEntry(..) is the best interpretation
> of what I want to do:
> ---
> const char* GetDirEntry(void *dirp)
>
>  Get next Unix file system directory entry. Returns 0 if no more entries.
> ---
> So, any help from around the world?
>
> --------------------------------------------------------------
> Jens Ivar Jřrdre, masterstud. in Experimental Nuclear Physics
> Addr.: Dep. of Phys., UiB, Allégt. 55, N-5007 BERGEN, NORWAY
> E-mail: JensIvar.Jordre@fi.uib.no, Phone office: (+47)55582734
> Web: http://www.fi.uib.no/~jens
>
> "Time's fun when you're having flies."
> -- Kermit the Frog
>
>
>



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