BaseLibCompressor.h
Go to the documentation of this file.
1 
2 // This source file is part of the ZipArchive Library Open Source distribution
3 // and is Copyrighted 2000 - 2022 by Artpol Software - Tadeusz Dracz
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // For the licensing details refer to the License.txt file.
11 //
12 // Web Site: https://www.artpol-software.com
14 
21 #if !defined(ZIPARCHIVE_BASELIBCOMPRESSOR_DOT_H)
22 #define ZIPARCHIVE_BASELIBCOMPRESSOR_DOT_H
23 
24 #if _MSC_VER > 1000
25 #pragma once
26 #endif
27 
28 #include "ZipExport.h"
29 #include "ZipCompressor.h"
30 #include "ZipCollections.h"
31 #include "ZipException.h"
32 
33 namespace ZipArchiveLib
34 {
35 
39 class ZIP_API CBaseLibCompressor : public CZipCompressor
40 {
41 public:
51  {
52  COptions()
53  {
54  m_bDetectLibMemoryLeaks = true;
55  }
56 
62  };
63 
71  :CZipCompressor(pStorage)
72  {
73  m_bDecompressionDone = false;
74  }
75 
76  void InitDecompression(CZipFileHeader* pFile, CZipCryptograph* pCryptograph)
77  {
78  CZipCompressor::InitDecompression(pFile, pCryptograph);
79  m_bDecompressionDone = false;
80  }
81 
83  {
84  EmptyPtrList();
85  }
86 protected:
87 
103  static void* _zipalloc(void* opaque, UINT items, UINT size)
104  {
105  void* p = new char[size * items];
106  if (opaque)
107  {
108  CZipPtrList<void*>* list = (CZipPtrList<void*>*) opaque;
109  list->AddTail(p);
110  }
111  return p;
112  }
113 
123  static void _zipfree(void* opaque, void* address)
124  {
125  if (opaque)
126  {
127  CZipPtrList<void*>* list = (CZipPtrList<void*>*) opaque;
128  CZipPtrListIter iter = list->Find(address);
129  if (list->IteratorValid(iter))
130  list->RemoveAt(iter);
131  }
132  delete[] (char*) address;
133  }
134 
139  void EmptyPtrList();
140 
150  virtual bool IsCodeErrorOK(int iErr) const = 0;
151 
159  void CheckForError(int iErr)
160  {
161  if (!IsCodeErrorOK(iErr))
162  ThrowError(iErr, true);
163  }
164 
173  void SetOpaque(void** opaque, const COptions* pOptions);
174 
179 private:
180  typedef CZipPtrList<void*>::iterator CZipPtrListIter;
181 
182 #if (_MSC_VER > 1000) && (defined ZIP_HAS_DLL)
183  #pragma warning (push)
184  #pragma warning( disable : 4251 ) // needs to have dll-interface to be used by clients of class
185 #endif
186 
187  CZipPtrList<void*> m_list;
188 
189 #if (_MSC_VER > 1000) && (defined ZIP_HAS_DLL)
190  #pragma warning( pop)
191 #endif
192 
193 };
194 
195 } // namespace
196 
197 #endif

The ZipArchive Library Copyright © 2000 - 2022 Artpol Software - Tadeusz Dracz. Generated at Sat Dec 17 2022 19:57:03.