Back to the WFC main page

CLZFile : CDummyFile

$Revision: 27 $

Description

This class makes it easy to play with LZ compressed files. It encapsulates the LZ API.

Data Members

None.

Methods

void Close( void )
Closes the LZ File.
BOOL Copy( const CLZFile& source )
BOOL Copy( const CLZFile * source )
Copies one CLZFile to this one.
BOOL GetExpandedName( LPTSTR name_of_compressed_file, CString& original_file_name )
Retrieves what the name of the expanded file will be.
BOOL Open( const char *channel_name, UINT style = OF_READ, CFileException* pError = NULL )
Opens an LZ compressed file for expanding.
UINT Read( void * buffer, UINT size_of_buffer )
Expands data stored in the compressed file.
LONG Seek( LONG offset, UINT from )
Moves the file pointer.
static void TranslateErrorCode( int error_code, CString& error_message )
Translates an error code ( LZERROR_xxx) into a human readable string.

Example

#include <wfc.h>

void test_CLZFile( LPTSTR lz_file_name )
{
   WFCTRACEINIT( TEXT( "test_CLZFile()" ) );

   CLZFile lz_file;

   if ( lz_file_name == (LPTSTR) NULL )
   {
      return;
   }

   CString expanded_name;

   lz_file.GetExpandedName( lz_file_name, expanded_name );

   _tprintf( TEXT( "LZ File \"%s\" expanded name is \"%s\"\n" ), lz_file_name, (LPCTSTR) expanded_name );

   if ( lz_file.Open( lz_file_name ) != FALSE )
   {
      CLZFile output_file;

      if ( output_file.Open( expanded_name, OF_CREATE ) != FALSE )
      {
         if ( output_file.Copy( lz_file ) != FALSE )
         {
            _tprintf( TEXT( "Successfully copied\n" ) );
         }
         else
         {
            CString error_message_string;
            CLZFile::TranslateErrorCode( (int) lz_file.GetErrorCode(), error_message_string );
            _tprintf( TEXT( "Can't Copy because %s\n" ), (LPCTSTR) error_message_string );
         }
      }
      else
      {
         CString error_message_string;
         CLZFile::TranslateErrorCode( (int) output_file.GetErrorCode(), error_message_string );
         _tprintf( TEXT( "Can't open LZ output file because %s\n" ), (LPCTSTR) error_message_string );
      }
   }
   else
   {
      CString error_message_string;
      CLZFile::TranslateErrorCode( (int) lz_file.GetErrorCode(), error_message_string );
      _tprintf( TEXT( "Can't open LZ file \"%s\" because \n" ), lz_file_name, (LPCTSTR) error_message_string );
   }
}

API's Used

CLZFile uses the following API's:
Copyright, 2000, Samuel R. Blackburn
$Workfile: lzfile.cpp $
$Modtime: 1/17/00 9:28a $