72 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			72 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| //
 | |
| // EX08CON.CPP
 | |
| //
 | |
| //  C++/DOS Example program for ArchiveLib 2.0
 | |
| //
 | |
| //  Copyright (c) Greenleaf Software, Inc. 1994 - 1996
 | |
| //  All Rights Reserved
 | |
| //
 | |
| // MEMBERS/FUNCTIONS DEMONSTRATED
 | |
| //
 | |
| //  ALStorage::GetCrc32()
 | |
| //  ALStorage::InitCrc32()
 | |
| //  ALFile::ALFile()
 | |
| //
 | |
| // DESCRIPTION
 | |
| //
 | |
| //  This program does a simple compression of a file to a memory buffer.
 | |
| //  It uses the raw compression function, instead of using an archive
 | |
| //  or ALCompressedObject as its target.  This is the sort of code you
 | |
| //  would use if you were compressing or expanding from your own types
 | |
| //  of proprietary files.
 | |
| //
 | |
| // REVISION HISTORY
 | |
| //
 | |
| //  February 1, 1996  2.0A  : Second release
 | |
| //
 | |
| 
 | |
| #include <conio.h>
 | |
| 
 | |
| #include "arclib.h"
 | |
| #include "filestor.h"
 | |
| #include "memstore.h"
 | |
| #include "copyengn.h"
 | |
| #include "_openf.h"
 | |
| 
 | |
| main()
 | |
| {
 | |
|  cout << "Archive Library 2.0\nEX08CON.CPP\n\n";
 | |
|  cout << "This program does a simple compression of a file to a memory buffer.\n";
 | |
|  cout << "It uses the raw compression function, instead of using an archive\n";
 | |
|  cout << "or ALCompressedObject as its target.  This is the sort of code you\n";
 | |
|  cout << "would use if you were compressing or expanding from your own types\n";
 | |
|  cout << "of proprietary files.\n\n";
 | |
|  getch();
 | |
| 
 | |
|  ALFile input( "EX08CON.CPP" );
 | |
|  ALMemory output( "In memory buffer" );
 | |
|  ALCompressor *engine = new ALCopyCompressor;
 | |
| 
 | |
| //
 | |
| // This shouldn't ever fail, which is the point of an assertion.
 | |
| //
 | |
| 
 | |
|  AL_ASSERT_OBJECT( engine, ALCompressor, "EX08CON.CPP" );
 | |
|  if ( input.Open() != AL_SUCCESS ) {
 | |
|      input.mStatus.SetError( AL_SUCCESS, "" );
 | |
|      input.mName = "..\\EXAMPLES\\EX08CON.CPP";
 | |
|      input.Open();
 | |
|  }
 | |
|  if ( input.mStatus != AL_SUCCESS ) {
 | |
|      cout << "Could not open EX08CON.CPP!\n";
 | |
|      return 1;
 | |
|  }
 | |
|  output.Create();
 | |
|  input.InitCrc32();
 | |
|  engine->Compress( input, output );
 | |
|  long crc = ~input.GetCrc32();
 | |
|  cout << "Crc = " << hex << crc << "\n";
 | |
|  delete engine;
 | |
|  return 1;
 | |
| }
 |