Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TArchiveFile.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/io:$Id$
0002 // Author: Fons Rademakers   30/6/04
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TArchiveFile
0013 #define ROOT_TArchiveFile
0014 
0015 #include "TObject.h"
0016 #include "TString.h"
0017 #include "TDatime.h"
0018 
0019 class TFile;
0020 class TArchiveMember;
0021 class TObjArray;
0022 
0023 
0024 class TArchiveFile : public TObject {
0025 
0026 private:
0027    TArchiveFile(const TArchiveFile&) = delete;            ///< Not implemented because TArchiveFile can not be copied.
0028    TArchiveFile& operator=(const TArchiveFile&) = delete; ///< Not implemented because TArchiveFile can not be copied.
0029 
0030 protected:
0031    TString         fArchiveName;  ///< Archive file name
0032    TString         fMemberName;   ///< Sub-file name
0033    Int_t           fMemberIndex;  ///< Index of sub-file in archive
0034    TFile          *fFile;         ///< File stream used to access the archive
0035    TObjArray      *fMembers;      ///< Members in this archive
0036    TArchiveMember *fCurMember;    ///< Current archive member
0037 
0038    static Bool_t ParseUrl(const char *url, TString &archive, TString &member, TString &type);
0039 
0040 public:
0041    TArchiveFile() : fArchiveName(""), fMemberName(""), fMemberIndex(-1), fFile(nullptr), fMembers(nullptr), fCurMember(nullptr) { }
0042    TArchiveFile(const char *archive, const char *member, TFile *file);
0043    ~TArchiveFile() override;
0044 
0045    virtual Int_t   OpenArchive() = 0;
0046    virtual Int_t   SetCurrentMember() = 0;
0047    virtual Int_t   SetMember(const char *member);
0048    virtual Int_t   SetMember(Int_t idx);
0049 
0050    Long64_t        GetMemberFilePosition() const;
0051    TArchiveMember *GetMember() const { return fCurMember; }
0052    TObjArray      *GetMembers() const { return fMembers; }
0053    Int_t           GetNumberOfMembers() const;
0054 
0055    const char     *GetArchiveName() const { return fArchiveName; }
0056    const char     *GetMemberName() const { return fMemberName; }
0057    Int_t           GetMemberIndex() const { return fMemberIndex; }
0058 
0059    static TArchiveFile *Open(const char *url, TFile *file);
0060 
0061    ClassDefOverride(TArchiveFile,1)  //An archive file containing multiple sub-files (like a ZIP archive)
0062 };
0063 
0064 
0065 class TArchiveMember : public TObject {
0066 
0067 friend class TArchiveFile;
0068 
0069 protected:
0070    TString    fName;          ///< Name of member
0071    TString    fComment;       ///< Comment field
0072    TDatime    fModTime;       ///< Modification time
0073    Long64_t   fPosition;      ///< Byte position in archive
0074    Long64_t   fFilePosition;  ///< Byte position in archive where member data starts
0075    Long64_t   fCsize;         ///< Compressed size
0076    Long64_t   fDsize;         ///< Decompressed size
0077    Bool_t     fDirectory;     ///< Flag indicating this is a directory
0078 
0079 public:
0080    TArchiveMember();
0081    TArchiveMember(const char *name);
0082    TArchiveMember(const TArchiveMember &member);
0083    TArchiveMember &operator=(const TArchiveMember &rhs);
0084    ~TArchiveMember() override { }
0085 
0086    const char *GetName() const override { return fName; }
0087    const char *GetComment() const { return fComment; }
0088    TDatime     GetModTime() const { return fModTime; }
0089    Long64_t    GetPosition() const { return fPosition; }
0090    Long64_t    GetFilePosition() const { return fFilePosition; }
0091    Long64_t    GetCompressedSize() const { return fCsize; }
0092    Long64_t    GetDecompressedSize() const { return fDsize; }
0093    Bool_t      IsDirectory() const { return fDirectory; }
0094 
0095    ClassDefOverride(TArchiveMember,1)  //An archive member file
0096 };
0097 
0098 #endif