Re: Directory listing in ROOT

From: Vassili Maroussov <vmarusov_at_fnal.gov>
Date: Mon, 14 Nov 2005 16:38:57 +0100


Dear Axel and Rene, thank you very much.

BTW, how to remove a (sent by mistake) posting from the roottalk?

Regards,

Vassili.

Axel Naumann wrote:

>Hi Vassili,
>
>use TSystem::GetPathInfo's flags, see
>http://root.cern.ch/root/html/TSystem#TSystem:GetPathInfo
>
>Axel.
>
>

Rene Brun wrote:

>See an example in the ROOT code itself, eg
>TSystemDirectory::GetListOfFiles(
>
>at
>
>http://root.cern.ch/root/htmldoc//src/TSystemDirectory.cxx.html#TSystemDirectory:GetListOfFiles
>
>
>
>Rene Brun
>
>
>Vassili Maroussov wrote:
>
>
>>Dear ROOTers,
>>
>>the macro attached gives the file list in a directory. How to recognize
>>whether particular <file> is an ordinary file or subdirectory?
>>
>>Thanks,
>>
>>Vassili.
>>
>>P.S. the attachment was missing in previous posting
>>
>>
>>
>>------------------------------------------------------------------------
>>
>>{
>> 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???
>> }
>> }
>>}
>>
>>
>
>
>
Received on Mon Nov 14 2005 - 16:39:57 MET

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:13 MET