156 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			156 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
//
 | 
						|
// SIMPAPP.CPP
 | 
						|
//
 | 
						|
//  Source file for ArchiveLib 2.0
 | 
						|
//
 | 
						|
//  Copyright (c) Greenleaf Software, Inc. 1994-1996
 | 
						|
//  All Rights Reserved
 | 
						|
//
 | 
						|
// CONTENTS
 | 
						|
//
 | 
						|
//  ALAppend()
 | 
						|
//  ALAppendVB()
 | 
						|
//
 | 
						|
// REVISION HISTORY
 | 
						|
//
 | 
						|
//   February 14, 1996  2.0A : New Release
 | 
						|
//
 | 
						|
 | 
						|
#include "arclib.h"
 | 
						|
#if !defined( AL_IBM )
 | 
						|
#pragma hdrstop
 | 
						|
#endif
 | 
						|
 | 
						|
#include "alsimple.h"
 | 
						|
#include "pkarc.h"
 | 
						|
 | 
						|
//
 | 
						|
// NAME
 | 
						|
//
 | 
						|
//  ALAppend()
 | 
						|
//
 | 
						|
// PLATFORMS/ENVIRONMENTS
 | 
						|
//
 | 
						|
//  Console  Windows  PM
 | 
						|
//  C++  C  VB  Delphi
 | 
						|
//
 | 
						|
// SHORT DESCRIPTION
 | 
						|
//
 | 
						|
//  The simplfied interface function to append files to a PKZip file.
 | 
						|
//
 | 
						|
// C/C++ SYNOPSIS
 | 
						|
//
 | 
						|
//  #include "alsimple.h"
 | 
						|
//
 | 
						|
//  int ALAppend( char *name,
 | 
						|
//                char *file_list,
 | 
						|
//                int strip_path,
 | 
						|
//                CALLBACK_FN callback )
 | 
						|
//
 | 
						|
// VB SYNOPSIS
 | 
						|
//
 | 
						|
//  Declare Function ALAppend Lib "AL20LWD" Alias "ALAppendVB"
 | 
						|
//  ( ByVal archive_name$,
 | 
						|
//    ByVal input_files$,
 | 
						|
//    ByVal strip_path%,
 | 
						|
//    ByVal text_window%,
 | 
						|
//    ByVal file_progress_window%,
 | 
						|
//    ByVal job_progress_window% ) As Integer
 | 
						|
//
 | 
						|
// DELPHI SYNOPSIS
 | 
						|
//
 | 
						|
// function ALAppend( archive_name : String;
 | 
						|
//                    input_files : String;
 | 
						|
//                    strip_path : integer;
 | 
						|
//                    text_window : Hwnd;
 | 
						|
//                    file_progress_window : Hwnd;
 | 
						|
//                    job_progress_window : Hwnd ) : integer;
 | 
						|
//
 | 
						|
// ARGUMENTS
 | 
						|
//
 | 
						|
//  archive_name      :  The name of a ZIP file.  It must already exist.
 | 
						|
//
 | 
						|
//  input_files       :  A list of file names, including wildcards.  File
 | 
						|
//                       names should be separated by white space or commas.
 | 
						|
//
 | 
						|
//  strip_path        :  A flag indicating whether or not the paths should
 | 
						|
//                       be stripped from the file names before the names
 | 
						|
//                       are written to the ZIP directory.
 | 
						|
//
 | 
						|
//  callback          :  C and C++ use a callback function for monitoring.
 | 
						|
//                       This function gets called periodically with
 | 
						|
//                       file names and progress ratios.
 | 
						|
//
 | 
						|
//  text_window       :  VB and Delphi get file names sent in ASCII to this
 | 
						|
//                       text_window.  A value of zero prevents messages
 | 
						|
//                       from being sent.
 | 
						|
//
 | 
						|
//  file_progress_window : VB and Delphi get the percentage of completion
 | 
						|
//                         for individual files sent to a window.  These
 | 
						|
//                         are ASCII values such as "75".
 | 
						|
//
 | 
						|
//  job_progress_window : VB and Delphi get the percentage of completion
 | 
						|
//                        for the complete job sent to a window.  These
 | 
						|
//                        are ASCII values such as "75".
 | 
						|
//
 | 
						|
// DESCRIPTION
 | 
						|
//
 | 
						|
//   The simplified ALAppend function just appends a batch of file
 | 
						|
//   to a ZIP file.  You don't get any flexibility when doing it this
 | 
						|
//   way, but it is nice and easy.  The only difference between the
 | 
						|
//   VB/Delphi and C/C++ versions is that one uses a callback function
 | 
						|
//   and the other gets messages via text windows.
 | 
						|
//
 | 
						|
// RETURNS
 | 
						|
//
 | 
						|
//  AL_SUCCESS if things went well, o/w an ArchiveLib error code.
 | 
						|
//
 | 
						|
// EXAMPLE
 | 
						|
//
 | 
						|
// SEE ALSO
 | 
						|
//
 | 
						|
// REVISION HISTORY
 | 
						|
//
 | 
						|
//   February 14, 1996  2.0A : New Release
 | 
						|
//
 | 
						|
 | 
						|
AL_LINKAGE int AL_FUNCTION ALAppend( char AL_DLL_FAR *name,
 | 
						|
                                     char AL_DLL_FAR *file_list,
 | 
						|
                                     int strip_path,
 | 
						|
                                     CALLBACK_FN callback )
 | 
						|
{
 | 
						|
    ALSimpleMonitor monitor( callback );
 | 
						|
    ALPkArchive arc( name );
 | 
						|
    arc.mfStripPathOnInsert = strip_path;
 | 
						|
    ALEntryList list( &monitor, PkTools() );
 | 
						|
    list.AddWildCardFiles( file_list );
 | 
						|
    list.UnmarkDuplicates( list );
 | 
						|
    int i = arc.Append( list );
 | 
						|
    return i;
 | 
						|
}
 | 
						|
 | 
						|
#if defined( AL_VB ) || defined( AL_VB32 )
 | 
						|
 | 
						|
extern "C" AL_LINKAGE
 | 
						|
int AL_FUNCTION ALAppendVB( char AL_DLL_FAR *name,
 | 
						|
                            char AL_DLL_FAR *file_list,
 | 
						|
                            int strip_path,
 | 
						|
                            HWND text_window,
 | 
						|
                            HWND file_progress_window,
 | 
						|
                            HWND job_progress_window )
 | 
						|
{
 | 
						|
    ALSimpleMonitor monitor( text_window,
 | 
						|
                             file_progress_window,
 | 
						|
                             job_progress_window );
 | 
						|
    ALPkArchive arc( name );
 | 
						|
    arc.mfStripPathOnInsert = strip_path;
 | 
						|
    ALEntryList list( &monitor, PkTools() );
 | 
						|
    list.AddWildCardFiles( file_list );
 | 
						|
    list.UnmarkDuplicates( list );
 | 
						|
    int i = arc.Append( list );
 | 
						|
    return i;
 | 
						|
}
 | 
						|
 | 
						|
#endif
 | 
						|
 |