SNAP Library 4.1, User Reference  2018-07-26 16:30:42
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
zipfl.h
Go to the documentation of this file.
1 #ifndef zipfl_h
2 #define zipfl_h
3 
4 //#//////////////////////////////////////////////
14 // Obsolete note (RS 2014/01/29): You can only load .gz files of uncompressed size <2GB. If you load some other format (like .bz2 or rar) there is no such limitation.
15 class TZipIn : public TSIn {
16 public:
18 private:
20  static const int MxBfL;
21  #ifdef GLib_WIN
22  HANDLE ZipStdoutRd, ZipStdoutWr;
23  #else
25  #endif
27  char* Bf;
28  int BfC, BfL;
29 private:
30  void FillBf();
31  int FindEol(int& BfN);
32  void CreateZipProcess(const TStr& Cmd, const TStr& ZipFNm);
33  static void FillFExtToCmdH();
34 private:
35  TZipIn();
36  TZipIn(const TZipIn&);
37  TZipIn& operator=(const TZipIn&);
38 public:
39  TZipIn(const TStr& FNm);
40  TZipIn(const TStr& FNm, bool& OpenedP);
41  static PSIn New(const TStr& FNm);
42  static PSIn New(const TStr& FNm, bool& OpenedP);
43  ~TZipIn();
44 
45  bool Eof() { return CurFPos==FLen && BfC==BfL; }
46  int Len() const { return int(FLen-CurFPos+BfL-BfC); }
47  char GetCh() { if (BfC==BfL){FillBf();} return Bf[BfC++]; }
48  char PeekCh() { if (BfC==BfL){FillBf();} return Bf[BfC]; }
49  int GetBf(const void* LBf, const TSize& LBfL);
50  bool GetNextLnBf(TChA& LnChA);
51 
52  uint64 GetFLen() const { return FLen; }
53  uint64 GetCurFPos() const { return CurFPos; }
54 
56  static bool IsZipFNm(const TStr& FNm) { return IsZipExt(FNm.GetFExt()); }
58  static bool IsZipExt(const TStr& FNmExt);
60  static TStr GetCmd(const TStr& ZipFNm);
62  static uint64 GetFLen(const TStr& ZipFNm);
63  static PSIn NewIfZip(const TStr& FNm) { return IsZipFNm(FNm) ? New(FNm) : TFIn::New(FNm); }
64 };
65 
66 //#//////////////////////////////////////////////
74 class TZipOut : public TSOut{
75 private:
76  static const TSize MxBfL;
78  #ifdef GLib_WIN
79  HANDLE ZipStdinRd, ZipStdinWr;
80  #else
82  #endif
83  char* Bf;
85 private:
86  void FlushBf();
87  void CreateZipProcess(const TStr& Cmd, const TStr& ZipFNm);
88  static void FillFExtToCmdH();
89 private:
90  TZipOut();
91  TZipOut(const TZipOut&);
92  TZipOut& operator=(const TZipOut&);
93 public:
94  TZipOut(const TStr& _FNm);
95  static PSOut New(const TStr& FNm);
96  ~TZipOut();
97 
98  int PutCh(const char& Ch);
99  int PutBf(const void* LBf, const TSize& LBfL);
100  void Flush();
101 
103  static bool IsZipFNm(const TStr& FNm) { return IsZipExt(FNm.GetFExt()); }
105  static bool IsZipExt(const TStr& FNmExt);
107  static TStr GetCmd(const TStr& ZipFNm);
108  static PSOut NewIfZip(const TStr& FNm) { return IsZipFNm(FNm) ? New(FNm) : TFOut::New(FNm); }
109 };
110 
111 #endif
bool Eof()
Definition: zipfl.h:45
int BfL
Definition: zipfl.h:28
FILE * ZipStdoutWr
Definition: zipfl.h:24
~TZipOut()
Definition: zipfl.cpp:360
static TStrStrH FExtToCmdH
Definition: zipfl.h:19
static TStr GetCmd(const TStr &ZipFNm)
Return a command-line string that is executed in order to decompress a file to standard output...
Definition: zipfl.cpp:421
static TStr GetCmd(const TStr &ZipFNm)
Return a command-line string that is executed in order to decompress a file to standard output...
Definition: zipfl.cpp:223
static PSOut New(const TStr &FNm, const bool &Append=false)
Definition: fl.cpp:442
static void FillFExtToCmdH()
Definition: zipfl.cpp:204
int PutCh(const char &Ch)
Definition: zipfl.cpp:371
static bool IsZipFNm(const TStr &FNm)
Check whether the file extension of FNm is that of a compressed file (.gz, .7z, .rar, .zip, .cab, .arj. bzip2).
Definition: zipfl.h:56
char * Bf
Definition: zipfl.h:83
uint64 CurFPos
Definition: zipfl.h:26
TSize BfL
Definition: zipfl.h:84
bool GetNextLnBf(TChA &LnChA)
Definition: zipfl.cpp:159
TStr GetFExt() const
Definition: dt.cpp:1421
static const int MxBfL
Definition: zipfl.h:20
static PSIn New(const TStr &FNm)
Definition: zipfl.cpp:122
Definition: fl.h:58
static PSIn New(const TStr &FNm)
Definition: fl.cpp:290
static PSIn NewIfZip(const TStr &FNm)
Definition: zipfl.h:63
unsigned long long uint64
Definition: bd.h:38
TZipIn & operator=(const TZipIn &)
size_t TSize
Definition: bd.h:58
char GetCh()
Definition: zipfl.h:47
Definition: zipfl.h:15
char * Bf
Definition: zipfl.h:27
char PeekCh()
Definition: zipfl.h:48
static TStr SevenZipPath
Definition: zipfl.h:17
static const TSize MxBfL
Definition: zipfl.h:76
static TStrStrH FExtToCmdH
Definition: zipfl.h:77
FILE * ZipStdoutRd
Definition: zipfl.h:24
Definition: fl.h:128
static bool IsZipExt(const TStr &FNmExt)
Check whether the file extension FNmExt is that of a compressed file (.gz, .7z, .rar, .zip, .cab, .arj. bzip2).
Definition: zipfl.cpp:199
static void FillFExtToCmdH()
Definition: zipfl.cpp:402
static PSOut NewIfZip(const TStr &FNm)
Definition: zipfl.h:108
int Len() const
Definition: zipfl.h:46
Definition: dt.h:201
int PutBf(const void *LBf, const TSize &LBfL)
Definition: zipfl.cpp:376
static PSOut New(const TStr &FNm)
Definition: zipfl.cpp:356
Definition: dt.h:412
static bool IsZipExt(const TStr &FNmExt)
Check whether the file extension FNmExt is that of a compressed file (.gz, .7z, .rar, .zip, .cab, .arj. bzip2).
Definition: zipfl.cpp:397
FILE * ZipStdinRd
Definition: zipfl.h:81
uint64 FLen
Definition: zipfl.h:26
Definition: hash.h:97
void FillBf()
Definition: zipfl.cpp:48
void CreateZipProcess(const TStr &Cmd, const TStr &ZipFNm)
Definition: zipfl.cpp:18
uint64 GetCurFPos() const
Definition: zipfl.h:53
int BfC
Definition: zipfl.h:28
~TZipIn()
Definition: zipfl.cpp:130
Definition: zipfl.h:74
void Flush()
Definition: zipfl.cpp:388
FILE * ZipStdinWr
Definition: zipfl.h:81
uint64 GetFLen() const
Definition: zipfl.h:52
int GetBf(const void *LBf, const TSize &LBfL)
Definition: zipfl.cpp:143
static bool IsZipFNm(const TStr &FNm)
Check whether the file extension of FNm is that of a compressed file (.gz, .7z, .rar, .zip, .cab, .arj. bzip2).
Definition: zipfl.h:103
void FlushBf()
Definition: zipfl.cpp:296
void CreateZipProcess(const TStr &Cmd, const TStr &ZipFNm)
Definition: zipfl.cpp:307
TZipOut & operator=(const TZipOut &)
int FindEol(int &BfN)
Definition: zipfl.cpp:183