Lhaz
tar.h
[詳解]
1 /*==========================================================================*/
2 /* Lhaz TARクラス lhaz@chitora.jp */
3 /*==========================================================================*/
4 #ifndef _CTAR_H
5 #define _CTAR_H
6 
7 #include <stdio.h>
8 #include <time.h>
9 #include "lhazarc.h"
10 #include "../zlib/zlib.h"
11 #include "mystr.h"
12 
13 class CTAR {
14 public:
16  //
17  CTAR(const MYSTR& arcname);
18  virtual ‾CTAR(void);
19  //
20  static CTAR* Create(ARCHIVE::TYPE type, gzFile fptar, FILE* fp, const char* arcname = NULL);
21  bool Get(unsigned long* crc = NULL);
22  bool SkipData(void);
23  char* GetMagicCode(void) { return MagicCode; }
24  char* GetName(void) const { return Name; }
25  LONGLONG GetSize(void) const { return Size; }
26  time_t GetTime(void) const { return Time; }
27  char GetType(void) const { return Type; }
28  bool IsDir(void) const { return mIsDir; }
29  COMPLETE Extract(bool& overwrite, bool& skipflag, bool verify, bool show_progress);
30  bool Compress(const char* name);
31  static long CalcSum(char* s, size_t size);
32  bool WriteHeader(FILE* fp);
33  bool WriteBlank(void);
34  virtual size_t TarRead(void *buf, size_t size, unsigned long* crc = NULL) = 0;
35 
36 protected:
37  LONGLONG Size;
38 
39 private:
40  static const char MAGIC_CODE[8];
41  static const char MAGIC_CODE_GNU[8];
42  static const char LONG_LINK[];
43  //
44  char* Name;
45  char Atrib[8];
46  char UserID[8];
47  char GroupID[8];
48  char SizeOct[12];
49  time_t Time;
50  char TimeOct[12];
51  long CheckSum;
52  char CheckSumOct[8];
53  char Type;
54  char Link[100];
55  char MagicCode[8];
56  char UserName[32];
57  char GroupName[32];
58  char MjDeviceNum[8];
59  char MnDeviceNum[8];
60  char LastAccessTime[12];
61  char CreateTime[12];
62  char Offset[12];
63  char Dummy[512 - 100 - 8 - 8 - 8 - 12 - 12 - 8 - 1 - 100 - 8 - 32 - 32 - 8 - 8 - 12 - 12 - 12];
64  char Prefix[155];
65  char Pad[12];
66  //
67  MYSTR ArcName;
68  long CalcedSum;
69  bool mIsDir;
70  //
71  bool ReadCalcSum(char* d, size_t size, long& sum, unsigned long* crc = NULL);
72  bool WriteHeader(void);
73  bool WriteData(const char* name);
74  bool isDir(char type, char* name);
75  virtual int TarSeek(fpos_t offset, int origin) = 0;
76  virtual size_t TarWrite(const void* buf, size_t size, bool eof = false) = 0;
77 
78 };
79 
80 #endif
Archive.
TYPE
Definition: lhazarc.h:28
static const char MAGIC_CODE[8]
Definition: tar.h:40
char Pad[12]
Definition: tar.h:65
char MagicCode[8]
Definition: tar.h:55
char LastAccessTime[12]
Definition: tar.h:60
char GroupName[32]
Definition: tar.h:57
virtual size_t TarRead(void *buf, size_t size, unsigned long *crc=NULL)=0
bool WriteHeader(void)
Definition: tar.cpp:420
char Link[100]
Definition: tar.h:54
bool Get(unsigned long *crc=NULL)
Get.
Definition: tar.cpp:84
Definition: tar.h:15
virtual ‾CTAR(void)
Destructor.
Definition: tar.cpp:61
char GetType(void) const
Definition: tar.h:27
char UserID[8]
Definition: tar.h:46
LONGLONG Size
Definition: tar.h:37
Definition: tar.h:15
Definition: tar.h:13
Definition: tar.h:15
char Dummy[512-100-8-8-8-12-12-8-1-100-8-32-32-8-8-12-12-12]
Definition: tar.h:63
Definition: tar.h:15
char SizeOct[12]
Definition: tar.h:48
char UserName[32]
Definition: tar.h:56
char * GetMagicCode(void)
Definition: tar.h:23
char Type
Definition: tar.h:53
long CalcedSum
Definition: tar.h:68
static CTAR * Create(ARCHIVE::TYPE type, gzFile fptar, FILE *fp, const char *arcname=NULL)
Create.
Definition: tar.cpp:69
char TimeOct[12]
Definition: tar.h:50
static const char MAGIC_CODE_GNU[8]
Definition: tar.h:41
char CreateTime[12]
Definition: tar.h:61
virtual int TarSeek(fpos_t offset, int origin)=0
static long CalcSum(char *s, size_t size)
CalcSum.
Definition: tar.cpp:395
bool mIsDir
Definition: tar.h:69
COMPLETE
Definition: tar.h:15
bool isDir(char type, char *name)
isDir
Definition: tar.cpp:180
long CheckSum
Definition: tar.h:51
char GroupID[8]
Definition: tar.h:47
char Prefix[155]
Definition: tar.h:64
LONGLONG GetSize(void) const
Definition: tar.h:25
bool IsDir(void) const
Definition: tar.h:28
time_t GetTime(void) const
Definition: tar.h:26
char * GetName(void) const
Definition: tar.h:24
char MnDeviceNum[8]
Definition: tar.h:59
MYSTR ArcName
Definition: tar.h:67
bool Compress(const char *name)
Compress.
Definition: tar.cpp:277
bool WriteData(const char *name)
Definition: tar.cpp:488
char Offset[12]
Definition: tar.h:62
char MjDeviceNum[8]
Definition: tar.h:58
char * Name
Definition: tar.h:44
char CheckSumOct[8]
Definition: tar.h:52
time_t Time
Definition: tar.h:49
bool WriteBlank(void)
WriteBlank.
Definition: tar.cpp:517
static const char LONG_LINK[]
Definition: tar.h:42
Definition: tar.h:15
bool ReadCalcSum(char *d, size_t size, long &sum, unsigned long *crc=NULL)
ReadCalcSum.
Definition: tar.cpp:407
CTAR(const MYSTR &arcname)
Constructor.
Definition: tar.cpp:28
virtual size_t TarWrite(const void *buf, size_t size, bool eof=false)=0
COMPLETE Extract(bool &overwrite, bool &skipflag, bool verify, bool show_progress)
Extract.
Definition: tar.cpp:207
char Atrib[8]
Definition: tar.h:45
bool SkipData(void)
SkipData.
Definition: tar.cpp:194