From 41ab8260f7b50bedbf06ea0effcb6147cb648685 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 13 Feb 2014 16:54:29 +0100 Subject: MCADefrag: Implemented recompression. This finalizes #639. --- Tools/MCADefrag/MCADefrag.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'Tools/MCADefrag/MCADefrag.h') diff --git a/Tools/MCADefrag/MCADefrag.h b/Tools/MCADefrag/MCADefrag.h index ef527863d..d7fa1fc6e 100644 --- a/Tools/MCADefrag/MCADefrag.h +++ b/Tools/MCADefrag/MCADefrag.h @@ -43,6 +43,14 @@ protected: cThread(cMCADefrag & a_Parent); protected: + /** The compression methods, as specified by the MCA compression method byte. */ + enum + { + COMPRESSION_GZIP = 1, + COMPRESSION_ZLIB = 2, + } ; + + cMCADefrag & m_Parent; /** The current compressed chunk data. Valid after a successful ReadChunk(). @@ -63,6 +71,10 @@ protected: /** Number of the sector where the next chunk will be written by WriteChunk(). */ int m_CurrentSectorOut; + /** Set to true when the chunk has been successfully uncompressed. Only used if recompression is active. + WriteChunk() tests this flag to decide whether to call Compress(). */ + bool m_IsChunkUncompressed; + /** Processes the specified file. */ void ProcessFile(const AString & a_FileName); @@ -80,6 +92,22 @@ protected: Returns true if successful. */ bool WriteChunk(cFile & a_File, Byte * a_LocationRaw); + /** Uncompresses the chunk data from m_CompressedChunkData into m_RawChunkData. + Returns true if successful, false on failure. */ + bool UncompressChunk(void); + + /** Uncompresses the chunk data from m_CompressedChunkData into m_RawChunkData, using Gzip. + Returns true if successful, false on failure. */ + bool UncompressChunkGzip(void); + + /** Uncompresses the chunk data from m_CompressedChunkData into m_RawChunkData, using Zlib. + Returns true if successful, false on failure. */ + bool UncompressChunkZlib(void); + + /** Compresses the chunk data from m_RawChunkData into m_CompressedChunkData. + Returns true if successful, false on failure. */ + bool CompressChunk(void); + // cIsThread overrides: virtual void Execute(void) override; } ; @@ -99,6 +127,9 @@ protected: /** The number of threads that should be started. Configurable on the command line. */ int m_NumThreads; + /** If set to true, the chunk data is recompressed while saving each MCA file. */ + bool m_ShouldRecompress; + /** Starts a new processing thread and adds it to cThreads. */ void StartThread(void); -- cgit v1.2.3