Logo ROOT  
Reference Guide
TArchiveFile.h
Go to the documentation of this file.
1 // @(#)root/io:$Id$
2 // Author: Fons Rademakers 30/6/04
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TArchiveFile
13 #define ROOT_TArchiveFile
14 
15 #include "TObject.h"
16 #include "TString.h"
17 #include "TDatime.h"
18 
19 class TFile;
20 class TArchiveMember;
21 class TObjArray;
22 
23 
24 class TArchiveFile : public TObject {
25 
26 private:
27  TArchiveFile(const TArchiveFile&) = delete; ///< Not implemented because TArchiveFile can not be copied.
28  TArchiveFile& operator=(const TArchiveFile&) = delete; ///< Not implemented because TArchiveFile can not be copied.
29 
30 protected:
31  TString fArchiveName; ///< Archive file name
32  TString fMemberName; ///< Sub-file name
33  Int_t fMemberIndex; ///< Index of sub-file in archive
34  TFile *fFile; ///< File stream used to access the archive
35  TObjArray *fMembers; ///< Members in this archive
36  TArchiveMember *fCurMember; ///< Current archive member
37 
38  static Bool_t ParseUrl(const char *url, TString &archive, TString &member, TString &type);
39 
40 public:
42  TArchiveFile(const char *archive, const char *member, TFile *file);
43  virtual ~TArchiveFile();
44 
45  virtual Int_t OpenArchive() = 0;
46  virtual Int_t SetCurrentMember() = 0;
47  virtual Int_t SetMember(const char *member);
48  virtual Int_t SetMember(Int_t idx);
49 
51  TArchiveMember *GetMember() const { return fCurMember; }
52  TObjArray *GetMembers() const { return fMembers; }
53  Int_t GetNumberOfMembers() const;
54 
55  const char *GetArchiveName() const { return fArchiveName; }
56  const char *GetMemberName() const { return fMemberName; }
57  Int_t GetMemberIndex() const { return fMemberIndex; }
58 
59  static TArchiveFile *Open(const char *url, TFile *file);
60 
61  ClassDef(TArchiveFile,1) //An archive file containing multiple sub-files (like a ZIP archive)
62 };
63 
64 
65 class TArchiveMember : public TObject {
66 
67 friend class TArchiveFile;
68 
69 protected:
70  TString fName; ///< Name of member
71  TString fComment; ///< Comment field
72  TDatime fModTime; ///< Modification time
73  Long64_t fPosition; ///< Byte position in archive
74  Long64_t fFilePosition; ///< Byte position in archive where member data starts
75  Long64_t fCsize; ///< Compressed size
76  Long64_t fDsize; ///< Decompressed size
77  Bool_t fDirectory; ///< Flag indicating this is a directory
78 
79 public:
81  TArchiveMember(const char *name);
82  TArchiveMember(const TArchiveMember &member);
84  virtual ~TArchiveMember() { }
85 
86  const char *GetName() const { return fName; }
87  const char *GetComment() const { return fComment; }
88  TDatime GetModTime() const { return fModTime; }
89  Long64_t GetPosition() const { return fPosition; }
91  Long64_t GetCompressedSize() const { return fCsize; }
92  Long64_t GetDecompressedSize() const { return fDsize; }
93  Bool_t IsDirectory() const { return fDirectory; }
94 
95  ClassDef(TArchiveMember,1) //An archive member file
96 };
97 
98 #endif
TArchiveFile
Class describing an archive file containing multiple sub-files, like a ZIP or TAR archive.
Definition: TArchiveFile.h:24
TArchiveMember::fCsize
Long64_t fCsize
Compressed size.
Definition: TArchiveFile.h:75
TArchiveMember::GetCompressedSize
Long64_t GetCompressedSize() const
Definition: TArchiveFile.h:91
TObjArray
An array of TObjects.
Definition: TObjArray.h:37
TArchiveFile::OpenArchive
virtual Int_t OpenArchive()=0
TArchiveMember::GetName
const char * GetName() const
Returns name of object.
Definition: TArchiveFile.h:86
TArchiveMember::fFilePosition
Long64_t fFilePosition
Byte position in archive where member data starts.
Definition: TArchiveFile.h:74
TArchiveFile::GetNumberOfMembers
Int_t GetNumberOfMembers() const
Returns number of members in archive.
Definition: TArchiveFile.cxx:79
TDatime.h
Long64_t
long long Long64_t
Definition: RtypesCore.h:73
TArchiveMember
Definition: TArchiveFile.h:65
TArchiveFile::GetArchiveName
const char * GetArchiveName() const
Definition: TArchiveFile.h:55
Int_t
int Int_t
Definition: RtypesCore.h:45
TArchiveFile::ParseUrl
static Bool_t ParseUrl(const char *url, TString &archive, TString &member, TString &type)
Try to determine if url contains an anchor specifying an archive member.
Definition: TArchiveFile.cxx:149
TArchiveMember::fDsize
Long64_t fDsize
Decompressed size.
Definition: TArchiveFile.h:76
TString
Basic string class.
Definition: TString.h:136
TArchiveFile::SetMember
virtual Int_t SetMember(const char *member)
Explicitely make the specified member the current member.
Definition: TArchiveFile.cxx:88
TArchiveFile::Open
static TArchiveFile * Open(const char *url, TFile *file)
Return proper archive file handler depending on passed url.
Definition: TArchiveFile.cxx:121
TArchiveFile::TArchiveFile
TArchiveFile(const TArchiveFile &)=delete
Not implemented because TArchiveFile can not be copied.
TArchiveMember::fDirectory
Bool_t fDirectory
Flag indicating this is a directory.
Definition: TArchiveFile.h:77
TArchiveFile::fFile
TFile * fFile
File stream used to access the archive.
Definition: TArchiveFile.h:34
TString.h
bool
TArchiveFile::GetMemberIndex
Int_t GetMemberIndex() const
Definition: TArchiveFile.h:57
TArchiveMember::GetDecompressedSize
Long64_t GetDecompressedSize() const
Definition: TArchiveFile.h:92
TArchiveFile::fCurMember
TArchiveMember * fCurMember
Current archive member.
Definition: TArchiveFile.h:36
TArchiveFile::GetMember
TArchiveMember * GetMember() const
Definition: TArchiveFile.h:51
TArchiveMember::fComment
TString fComment
Comment field.
Definition: TArchiveFile.h:71
TArchiveMember::IsDirectory
Bool_t IsDirectory() const
Definition: TArchiveFile.h:93
TArchiveFile::operator=
TArchiveFile & operator=(const TArchiveFile &)=delete
Not implemented because TArchiveFile can not be copied.
TArchiveFile::TArchiveFile
TArchiveFile()
Definition: TArchiveFile.h:41
TArchiveMember::GetFilePosition
Long64_t GetFilePosition() const
Definition: TArchiveFile.h:90
TArchiveMember::fPosition
Long64_t fPosition
Byte position in archive.
Definition: TArchiveFile.h:73
TArchiveMember::~TArchiveMember
virtual ~TArchiveMember()
Definition: TArchiveFile.h:84
TArchiveMember::TArchiveMember
TArchiveMember()
Default ctor.
Definition: TArchiveFile.cxx:211
TArchiveFile::GetMemberFilePosition
Long64_t GetMemberFilePosition() const
Return position in archive of current member.
Definition: TArchiveFile.cxx:71
TArchiveFile::~TArchiveFile
virtual ~TArchiveFile()
Dtor.
Definition: TArchiveFile.cxx:63
TArchiveMember::fModTime
TDatime fModTime
Modification time.
Definition: TArchiveFile.h:72
TArchiveFile::SetCurrentMember
virtual Int_t SetCurrentMember()=0
TArchiveMember::GetComment
const char * GetComment() const
Definition: TArchiveFile.h:87
TArchiveMember::GetPosition
Long64_t GetPosition() const
Definition: TArchiveFile.h:89
TArchiveMember::operator=
TArchiveMember & operator=(const TArchiveMember &rhs)
Assignment operator.
Definition: TArchiveFile.cxx:255
TFile
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:54
TArchiveMember::GetModTime
TDatime GetModTime() const
Definition: TArchiveFile.h:88
TArchiveMember::fName
TString fName
Name of member.
Definition: TArchiveFile.h:70
TArchiveFile::GetMemberName
const char * GetMemberName() const
Definition: TArchiveFile.h:56
TArchiveFile::GetMembers
TObjArray * GetMembers() const
Definition: TArchiveFile.h:52
TArchiveFile::fArchiveName
TString fArchiveName
Archive file name.
Definition: TArchiveFile.h:31
TObject.h
file
Definition: file.py:1
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TArchiveFile::fMemberName
TString fMemberName
Sub-file name.
Definition: TArchiveFile.h:32
name
char name[80]
Definition: TGX11.cxx:110
TArchiveFile::fMemberIndex
Int_t fMemberIndex
Index of sub-file in archive.
Definition: TArchiveFile.h:33
TArchiveFile::fMembers
TObjArray * fMembers
Members in this archive.
Definition: TArchiveFile.h:35
TDatime
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition: TDatime.h:37
type
int type
Definition: TGX11.cxx:121
int