ROOT  6.06/09
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 #ifndef ROOT_TObject
16 #include "TObject.h"
17 #endif
18 #ifndef ROOT_TString
19 #include "TString.h"
20 #endif
21 #ifndef ROOT_TDatime
22 #include "TDatime.h"
23 #endif
24 
25 class TFile;
26 class TArchiveMember;
27 class TObjArray;
28 
29 
30 class TArchiveFile : public TObject {
31 
32 private:
33  TArchiveFile(const TArchiveFile&); ///< Not implemented because TArchiveFile can not be copied.
34  TArchiveFile& operator=(const TArchiveFile&); ///< Not implemented because TArchiveFile can not be copied.
35 
36 protected:
37  TString fArchiveName; ///< Archive file name
38  TString fMemberName; ///< Sub-file name
39  Int_t fMemberIndex; ///< Index of sub-file in archive
40  TFile *fFile; ///< File stream used to access the archive
41  TObjArray *fMembers; ///< Members in this archive
42  TArchiveMember *fCurMember; ///< Current archive member
43 
44  static Bool_t ParseUrl(const char *url, TString &archive, TString &member, TString &type);
45 
46 public:
47  TArchiveFile() : fArchiveName(""), fMemberName(""), fMemberIndex(-1), fFile(0), fMembers(0), fCurMember(0) { }
48  TArchiveFile(const char *archive, const char *member, TFile *file);
49  virtual ~TArchiveFile();
50 
51  virtual Int_t OpenArchive() = 0;
52  virtual Int_t SetCurrentMember() = 0;
53  virtual Int_t SetMember(const char *member);
54  virtual Int_t SetMember(Int_t idx);
55 
57  TArchiveMember *GetMember() const { return fCurMember; }
58  TObjArray *GetMembers() const { return fMembers; }
59  Int_t GetNumberOfMembers() const;
60 
61  const char *GetArchiveName() const { return fArchiveName; }
62  const char *GetMemberName() const { return fMemberName; }
63  Int_t GetMemberIndex() const { return fMemberIndex; }
64 
65  static TArchiveFile *Open(const char *url, TFile *file);
66 
67  ClassDef(TArchiveFile,1) //An archive file containing multiple sub-files (like a ZIP archive)
68 };
69 
70 
71 class TArchiveMember : public TObject {
72 
73 friend class TArchiveFile;
74 
75 protected:
76  TString fName; ///< Name of member
77  TString fComment; ///< Comment field
78  TDatime fModTime; ///< Modification time
79  Long64_t fPosition; ///< Byte position in archive
80  Long64_t fFilePosition; ///< Byte position in archive where member data starts
81  Long64_t fCsize; ///< Compressed size
82  Long64_t fDsize; ///< Decompressed size
83  Bool_t fDirectory; ///< Flag indicating this is a directory
84 
85 public:
87  TArchiveMember(const char *name);
88  TArchiveMember(const TArchiveMember &member);
90  virtual ~TArchiveMember() { }
91 
92  const char *GetName() const { return fName; }
93  const char *GetComment() const { return fComment; }
94  TDatime GetModTime() const { return fModTime; }
95  Long64_t GetPosition() const { return fPosition; }
97  Long64_t GetCompressedSize() const { return fCsize; }
98  Long64_t GetDecompressedSize() const { return fDsize; }
99  Bool_t IsDirectory() const { return fDirectory; }
100 
101  ClassDef(TArchiveMember,1) //An archive member file
102 };
103 
104 #endif
virtual ~TArchiveMember()
Definition: TArchiveFile.h:90
Class describing an archive file containing multiple sub-files, like a ZIP or TAR archive...
Definition: TArchiveFile.h:30
Int_t fMemberIndex
Index of sub-file in archive.
Definition: TArchiveFile.h:39
An array of TObjects.
Definition: TObjArray.h:39
virtual ~TArchiveFile()
Dtor.
TObjArray * fMembers
Members in this archive.
Definition: TArchiveFile.h:41
long long Long64_t
Definition: RtypesCore.h:69
const char * GetName() const
Returns name of object.
Definition: TArchiveFile.h:92
TString fComment
Comment field.
Definition: TArchiveFile.h:77
TDatime GetModTime() const
Definition: TArchiveFile.h:94
virtual Int_t SetMember(const char *member)
Explicitely make the specified member the current member.
TFile * fFile
File stream used to access the archive.
Definition: TArchiveFile.h:40
Long64_t GetFilePosition() const
Definition: TArchiveFile.h:96
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:45
static TArchiveFile * Open(const char *url, TFile *file)
Return proper archive file handler depending on passed url.
Long64_t fDsize
Decompressed size.
Definition: TArchiveFile.h:82
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TString fMemberName
Sub-file name.
Definition: TArchiveFile.h:38
TString fArchiveName
Archive file name.
Definition: TArchiveFile.h:37
Bool_t IsDirectory() const
Definition: TArchiveFile.h:99
TArchiveMember * fCurMember
Current archive member.
Definition: TArchiveFile.h:42
TArchiveFile & operator=(const TArchiveFile &)
Not implemented because TArchiveFile can not be copied.
TString fName
Name of member.
Definition: TArchiveFile.h:76
TObjArray * GetMembers() const
Definition: TArchiveFile.h:58
#define ClassDef(name, id)
Definition: Rtypes.h:254
Long64_t GetDecompressedSize() const
Definition: TArchiveFile.h:98
const char * GetArchiveName() const
Definition: TArchiveFile.h:61
const char * GetComment() const
Definition: TArchiveFile.h:93
Long64_t fPosition
Byte position in archive.
Definition: TArchiveFile.h:79
Int_t GetMemberIndex() const
Definition: TArchiveFile.h:63
Long64_t GetCompressedSize() const
Definition: TArchiveFile.h:97
Long64_t GetPosition() const
Definition: TArchiveFile.h:95
TDatime fModTime
Modification time.
Definition: TArchiveFile.h:78
virtual Int_t OpenArchive()=0
Bool_t fDirectory
Flag indicating this is a directory.
Definition: TArchiveFile.h:83
int type
Definition: TGX11.cxx:120
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.
TArchiveMember & operator=(const TArchiveMember &rhs)
Assignment operator.
Int_t GetNumberOfMembers() const
Returns number of members in archive.
virtual Int_t SetCurrentMember()=0
#define name(a, b)
Definition: linkTestLib0.cpp:5
const char * GetMemberName() const
Definition: TArchiveFile.h:62
Mother of all ROOT objects.
Definition: TObject.h:58
Long64_t fCsize
Compressed size.
Definition: TArchiveFile.h:81
Long64_t GetMemberFilePosition() const
Return position in archive of current member.
Long64_t fFilePosition
Byte position in archive where member data starts.
Definition: TArchiveFile.h:80
TArchiveMember * GetMember() const
Definition: TArchiveFile.h:57
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition: TDatime.h:39