Re: file size

From: Gerri Ganis <>
Date: Mon, 23 Oct 2006 10:12:37 +0200


TSystem::GetPathInfo is the equivalent of the posix stat function:

     FileStat_t fst;
     gSystem->GetPathInfo("<path>", fst);

A set of macros is available in TSystem.h to find the nature of the path: R_ISDIR(fst.fMode) will be true for directories and R_ISREG(fst.fMode) will be true for regular files.

For the size, for files you can use fst.fSize; for directories, what do you mean exactly for directory size? To get the number of entries in the directory
you have to open the directory and loop over its content:

    Int_t dir_entries = 0;
    void *dir = gSystem->OpenDirectory("<dir>")     while (gSystem->GetDirEntry(dir))


G. Ganis

Margar Simonyan wrote:

> Hello
> I wonder if within ROOT there is a way to get file or directory size.
> In TSystemDirectory and TSystemFile classes I found no such functions.
> Best regards,
> Margar Simonyan

  Gerardo GANIS    PH Department, CERN
        address    CERN, CH 1211 Geneve 23  
                   room: 32-RC-017, tel / fax: +412276 76439 / 69133
Received on Mon Oct 23 2006 - 10:13:31 MEST

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:32:01 MET