ROOT logo
HYDRA - THE HADES ANALYSIS PACKAGE » UTIL » HZip

class HZip: public TObject

_HADES_CLASS_DESCRIPTION

 HZip

 A helper class to read/work with zip file containing
 many root files. Those files can be typically produced
 by :
    zip -j -n root myzipname myrootfiles

 Note: root files will not be compressed, directory names
 ignored. It's a flat files structure. Purpose of the
 ziping of many root files into on zip archive is
 to improve the handling of many small files and reduce
 the load on the file system.

 To make the daily work more easy a command line executable hzip
 is provided to produce and work with those zip files:

 usage: hzip -o zipfile [-i filefilter] [-f filelist] [-u outputdir] [-msth]
	          -f input ascii filelist (1 file per line)
                -h help
                -i input filefilter (like "be*.root")
                -l list file in zip files
	          -m maxsize of file [bytes] (default = 2 Gbyte, will be splitted if larger)
	          -o outputzip file name (required)
                -s save mode. do not overide existing zip files (default is overwrite)
	          -t test. show what would be done
	          -u dir unzip zip files to dir
                -w print in which file membername is contained
	           examples:
                    test zip root files      : hzip -t -o test.zip -i "/mydir/be*.root"
	              zip root files           : hzip -o test.zip -i "/mydir/be*.root"
	              zip root files from list : hzip -o test.zip -f filelist
	              unzip root files to dir  : hzip -i "test_*.zip" -u /mydir
	              list files in zip files  : hzip -i "test_*.zip" -l

 from the normal terminal.
 HZip provides the functionality to access, list and files from
 a root macro.


 examples:

  TChain* chain =  new TChain("myTree");
  HZip::makeChain("my.zip",chain);            // add all root files to chain
  HZip::makeChainGlob("my*.zip",chain);       // add all root files of all matching zip files to chain
  HZip::makeChainList("filelist.txt",chain);  // add all root files of all zip files in filelist to chain

  chain->GetEntries(); // access all files and get number of entries
  chain->ls();         // list all files in chain with number of entries

  Bool_t HZip::isInside("my.zip","my.root"); // is my.root contained in my.zip?
  Int_t  HZip::list("my.zip",".*");          // list all files which match the pattern
  Int_t  HZip::getList("my.zip",list,".*");  // return to TList list all files which match the pattern
  Bool_t HZip::unzip("my.zip","mydir");      // unzip file to directory
  Bool_t HZip::addFile("my.zip","my.root");  // add this root file to the zip file
  Bool_t HZip::addFiles("my.zip",list);      // add all root files from TList list to the zip file

Function Members (Methods)

public:
HZip()
HZip(const HZip&)
virtual~HZip()
voidTObject::AbstractMethod(const char* method) const
static Bool_taddFile(TString zipname, TString membername, Int_t mode = 0)
static Bool_taddFiles(TString zipname, TList* list, Int_t mode = 0)
virtual voidTObject::AppendPad(Option_t* option = "")
virtual voidTObject::Browse(TBrowser* b)
static Bool_tchainToTObjArray(TChain* chain = 0, TObjArray* filenames = 0)
static TClass*Class()
virtual const char*TObject::ClassName() const
virtual voidTObject::Clear(Option_t* = "")
virtual TObject*TObject::Clone(const char* newname = "") const
virtual Int_tTObject::Compare(const TObject* obj) const
virtual voidTObject::Copy(TObject& object) const
virtual voidTObject::Delete(Option_t* option = "")MENU
virtual Int_tTObject::DistancetoPrimitive(Int_t px, Int_t py)
virtual voidTObject::Draw(Option_t* option = "")
virtual voidTObject::DrawClass() constMENU
virtual TObject*TObject::DrawClone(Option_t* option = "") constMENU
virtual voidTObject::Dump() constMENU
virtual voidTObject::Error(const char* method, const char* msgfmt) const
virtual voidTObject::Execute(const char* method, const char* params, Int_t* error = 0)
virtual voidTObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0)
virtual voidTObject::ExecuteEvent(Int_t event, Int_t px, Int_t py)
static Bool_texists(TString name, Bool_t silent = kFALSE, Bool_t isZip = kTRUE)
virtual voidTObject::Fatal(const char* method, const char* msgfmt) const
virtual TObject*TObject::FindObject(const char* name) const
virtual TObject*TObject::FindObject(const TObject* obj) const
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
virtual const char*TObject::GetIconName() const
static Int_tgetList(TString name, TList* list, TString filter = ".*", Int_t size = 0, Int_t time = 0)
virtual const char*TObject::GetName() const
virtual char*TObject::GetObjectInfo(Int_t px, Int_t py) const
static Bool_tTObject::GetObjectStat()
virtual Option_t*TObject::GetOption() const
virtual const char*TObject::GetTitle() const
virtual UInt_tTObject::GetUniqueID() const
static TObjArray*glob(TString pattern)
virtual Bool_tTObject::HandleTimer(TTimer* timer)
virtual ULong_tTObject::Hash() const
virtual voidTObject::Info(const char* method, const char* msgfmt) const
virtual Bool_tTObject::InheritsFrom(const char* classname) const
virtual Bool_tTObject::InheritsFrom(const TClass* cl) const
virtual voidTObject::Inspect() constMENU
voidTObject::InvertBit(UInt_t f)
virtual TClass*IsA() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tTObject::IsFolder() const
static Bool_tisInside(TString name, Bool_t print = kFALSE)
static Bool_tisInside(TString zipname, TString membername, Bool_t print = kFALSE)
Bool_tTObject::IsOnHeap() const
virtual Bool_tTObject::IsSortable() const
Bool_tTObject::IsZombie() const
static Int_tlist(TString name, TString filter = ".*", Int_t size = 0, Int_t time = 0)
virtual voidTObject::ls(Option_t* option = "") const
static Bool_tmakeChain(TString zipname, TChain* chain = 0, TString filter = ".*", Int_t size = 0, Int_t time = 0)
static Bool_tmakeChainGlob(TString expressionzip, TChain* chain = 0, TString filter = ".*", Int_t size = 0, Int_t time = 0)
static Bool_tmakeChainList(TString listfile, TChain* chain = 0, TString filter = ".*", Int_t size = 0, Int_t time = 0)
voidTObject::MayNotUse(const char* method) const
virtual Bool_tTObject::Notify()
voidTObject::Obsolete(const char* method, const char* asOfVers, const char* removedFromVers) const
static voidTObject::operator delete(void* ptr)
static voidTObject::operator delete(void* ptr, void* vp)
static voidTObject::operator delete[](void* ptr)
static voidTObject::operator delete[](void* ptr, void* vp)
void*TObject::operator new(size_t sz)
void*TObject::operator new(size_t sz, void* vp)
void*TObject::operator new[](size_t sz)
void*TObject::operator new[](size_t sz, void* vp)
HZip&operator=(const HZip&)
virtual voidTObject::Paint(Option_t* option = "")
virtual voidTObject::Pop()
virtual voidTObject::Print(Option_t* option = "") const
virtual Int_tTObject::Read(const char* name)
static TObjArray*readFileList(TString listfile)
virtual voidTObject::RecursiveRemove(TObject* obj)
voidTObject::ResetBit(UInt_t f)
virtual voidTObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU
virtual voidTObject::SavePrimitive(ostream& out, Option_t* option = "")
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
virtual voidTObject::SetDrawOption(Option_t* option = "")MENU
static voidTObject::SetDtorOnly(void* obj)
static voidTObject::SetObjectStat(Bool_t stat)
virtual voidTObject::SetUniqueID(UInt_t uid)
virtual voidShowMembers(TMemberInspector&)
static Bool_tsplitName(TString fullname, TString& zipname, TString& membername)
virtual voidStreamer(TBuffer&)
voidStreamerNVirtual(TBuffer& ClassDef_StreamerNVirtual_b)
virtual voidTObject::SysError(const char* method, const char* msgfmt) const
static Bool_ttest(TString zipname)
Bool_tTObject::TestBit(UInt_t f) const
Int_tTObject::TestBits(UInt_t f) const
static Bool_tunzip(TString zipname, TString outDir = "")
virtual voidTObject::UseCurrentStyle()
virtual voidTObject::Warning(const char* method, const char* msgfmt) const
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const
protected:
virtual voidTObject::DoError(int level, const char* location, const char* fmt, va_list va) const
voidTObject::MakeZombie()

Data Members

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

HZip()
{}
virtual ~HZip()
{}
TObjArray* glob(TString pattern)
 Expand 'pattern' as it would be done by the shell (see sh(1)):
 '*', '?', '~', '$ENVIRONMENT_VARIABLE' and '[', ']' are expanded. In case
 the expansion is successful, a TObjArray of TObjStrings with the
 names of all existing files is returned - otherwise NULL.

 The returned TObjArray must be deleted by the caller of the function!

 This example returns all existing .root files in /tmp as well as all .root
 files in your home directory starting with the characters 'a', 'b', 'c'
 and 'e':

 TObjArray* files = HTool::glob( "/tmp/*.root $HOME/[a-c,e]*.root" );
 if (files)
 {
    TObjString* name = NULL;
    TIterator*  file = files->MakeIterator();
    while ((name = (TObjString*)file->Next()))
    {
       Char_t* input = name->GetString.Data(); ...
    }
    delete files;
 }
TObjArray* readFileList(TString listfile)
 read inputfiles form list (one file per line)
 and add them to an TObjArray. The pointer to
 the array is returned. In case of an error or
 if no files are contained the pointer is NULL.
 The user must take care of deleting the array.
Bool_t chainToTObjArray(TChain* chain = 0, TObjArray* filenames = 0)
  add all filenames of TChain to TObjArray
Bool_t exists(TString name, Bool_t silent = kFALSE, Bool_t isZip = kTRUE)
 returns kTRUE if file exists and ends with .zip
Bool_t splitName(TString fullname, TString& zipname, TString& membername)
 if filename is   .zip#membername the
 name is splitted into the zip file name and
 the archive member name. return kTRUE
 if success els kFALSE
Bool_t isInside(TString name, Bool_t print = kFALSE)
 test if the member  (format: zipfilename.zip#membername)
 is inside the zip file. Return kTRUE if
 success else kFALSE
Bool_t isInside(TString zipname, TString membername, Bool_t print = kFALSE)
 test if the member is inside the zip file.
 Return kTRUE if success else kFALSE
Int_t list(TString name, TString filter = ".*", Int_t size = 0, Int_t time = 0)
 lists the members of the zip file which pass
 the name filter (see TRegexp). returns the number
 of matched files
Int_t getList(TString name, TList* list, TString filter = ".*", Int_t size = 0, Int_t time = 0)
 fills a list with the members of the zip file which pass
 the name filter (see TRegexp). returns the number
 of matched files
Bool_t makeChain(TString zipname, TChain* chain = 0, TString filter = ".*", Int_t size = 0, Int_t time = 0)
 adds all root members of the zip file matching the filter
 to TChain (has to be created before)
Bool_t makeChainGlob(TString expressionzip, TChain* chain = 0, TString filter = ".*", Int_t size = 0, Int_t time = 0)
 adds all root members match the filter of all zip files matching the expression
 to TChain (has to be created before)
Bool_t makeChainList(TString listfile, TChain* chain = 0, TString filter = ".*", Int_t size = 0, Int_t time = 0)
 adds all root members match the filter of all zip files matching the expression
 to TChain (has to be created before). The file list should contain
 one filename perline.
Bool_t addFile(TString zipname, TString membername, Int_t mode = 0)
 mode = 0  ==> do not replace existing members and warn
 mode = 1  ==> do not replace existing members and do not warn
 mode = 2  ==> replace existing members and do not warn
Bool_t addFiles(TString zipname, TList* list, Int_t mode = 0)
 mode = 0  ==> do not replace existing members and warn
 mode = 1  ==> do not replace existing members and do not warn
 mode = 2  ==> replace existing members and do not warn
Bool_t test(TString zipname)
 run unzip test on zipfile
Bool_t unzip(TString zipname, TString outDir = "")
 unzip content of zipfile to outDir (optional, default is local dir)