[videodb] Remove nested transaction when saving state after stopping PVR playback
[xbmc.git] / xbmc / filesystem / ZipFile.h
blob1b09e5c80bfa84fc236730765fb1b45466286b5b
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include "File.h"
12 #include "IFile.h"
13 #include "ZipManager.h"
15 #include <zlib.h>
17 namespace XFILE
19 class CZipFile : public IFile
21 public:
22 CZipFile();
23 ~CZipFile() override;
25 int64_t GetPosition() override;
26 int64_t GetLength() override;
27 bool Open(const CURL& url) override;
28 bool Exists(const CURL& url) override;
29 int Stat(struct __stat64* buffer) override;
30 int Stat(const CURL& url, struct __stat64* buffer) override;
31 ssize_t Read(void* lpBuf, size_t uiBufSize) override;
32 //virtual bool ReadString(char *szLine, int iLineLength);
33 int64_t Seek(int64_t iFilePosition, int iWhence = SEEK_SET) override;
34 void Close() override;
36 //NOTE: gzip doesn't work. use DecompressGzip() instead
37 int UnpackFromMemory(std::string& strDest, const std::string& strInput, bool isGZ=false);
39 /*! Decompress gzip encoded buffer in-memory */
40 static bool DecompressGzip(const std::string& in, std::string& out);
42 private:
43 bool InitDecompress();
44 bool FillBuffer();
45 void DestroyBuffer(void* lpBuffer, int iBufSize);
46 CFile mFile;
47 SZipEntry mZipItem;
48 int64_t m_iFilePos = 0; // position in _uncompressed_ data read
49 int64_t m_iZipFilePos = 0; // position in _compressed_ data
50 int m_iAvailBuffer = 0;
51 z_stream m_ZStream;
52 char m_szBuffer[65535]; // 64k buffer for compressed data
53 char* m_szStringBuffer;
54 char* m_szStartOfStringBuffer; // never allocated!
55 size_t m_iDataInStringBuffer;
56 int m_iRead;
57 bool m_bFlush = false;
58 bool m_bCached;