Skip to content
Snippets Groups Projects
Select Git revision
  • 9ca500f78387ba9ff289b58d0c2683810ef2dae6
  • master default protected
  • dof-renumbering
  • gdemesy-master-patch-30528
  • eval-space-time
  • oscillating_multiharm
  • MH_movement
  • axisqu
  • write_vtu_and_ensight_formats
  • movingband
  • CP_1972_add_vtu_file_writing
  • mortar
  • fast_freq_sweep_Resolution
  • applyresolvent_again
  • marteaua-master-patch-54323
  • patch-1
  • binde-master-patch-08072
  • binde-master-patch-52461
  • BCGSL
  • resolvent
  • TreeElementsOf
  • getdp_3_5_0
  • getdp_3_4_0
  • getdp_3_3_0
  • getdp_3_2_0
  • getdp_3_1_0
  • getdp_3_0_4
  • getdp_3_0_3
  • getdp_3_0_2
  • getdp_3_0_1
  • getdp_3_0_0
  • onelab_mobile_2.1.0
  • getdp_2_11_3 protected
  • getdp_2_11_2 protected
  • getdp_2_11_1 protected
  • getdp_2_11_0 protected
  • getdp_2_10_0 protected
  • getdp_2_9_2 protected
  • getdp_2_9_1 protected
  • getdp_2_9_0 protected
  • getdp_2_8_0 protected
41 results

F_Misc.cpp

Blame
  • example.cpp 1.32 KiB
    // ZipExample.cpp : Defines the entry point for the console application.
    //
    
    #include "stdafx.h"
    #include "zipper.h"
    #include "unzipper.h"
    #include <fstream>
    
    using namespace std;
    using namespace ziputils;
    
    void zip()
    {
    	const char* Filenames[] = {"unzipper.cpp", "unzipper.h", "zipper.cpp", "zipper.h"};
    	unsigned int nCount = sizeof( Filenames )/sizeof( char* );
    
    	zipper zipFile;
    	zipFile.open("test.zip");
    
    	// add files to the zip file
    	for ( unsigned int i = 0; i < nCount; i++ )
    	{
    		ifstream file( Filenames[i], ios::in | ios::binary );
    		if ( file.is_open() )
    		{
    			zipFile.addEntry( Filenames[i] );
    			zipFile << file;
    		}
    	}
    	zipFile.close();
    }
    
    void zipFolder()
    {
    	// append the existing file
    	zipper zipFile;
    	zipFile.open("test.zip", true);
    
    	// add file into a folder
    	ifstream file( "unzipper.cpp", ios::in | ios::binary );
    	if ( file.is_open() )
    	{
    		zipFile.addEntry( "/Folder/unzipper.cpp" );
    		zipFile << file;
    	}
    	zipFile.close();
    }
    
    void unzip()
    {
    	unzipper zipFile;
    	zipFile.open("test.zip");
    	auto filenames = zipFile.getFilenames();
    	
    	for ( auto it = filenames.begin(); it != filenames.end(); it++ )
    	{
    		zipFile.openEntry( (*it).c_str() );
    		zipFile >> std::cout;
    	}
    }
    
    int main(int argc, char* argv[])
    {
    	zip();
    	zipFolder();
    	unzip();
    	return 0;
    }