Skip to content
Snippets Groups Projects
Select Git revision
  • 839368ab160631dfe3204404889f44739e8d0f5c
  • master default protected
  • hierarchical-basis
  • alphashapes
  • bl
  • relaying
  • new_export_boris
  • oras_vs_osm
  • reassign_partitions
  • distributed_fwi
  • rename-classes
  • fix/fortran-api-example-t4
  • robust_partitions
  • reducing_files
  • fix_overlaps
  • 3115-issue-fix
  • 3023-Fillet2D-Update
  • convert_fdivs
  • tmp_jcjc24
  • fixedMeshIF
  • save_edges
  • gmsh_4_14_0
  • gmsh_4_13_1
  • gmsh_4_13_0
  • gmsh_4_12_2
  • gmsh_4_12_1
  • gmsh_4_12_0
  • gmsh_4_11_1
  • gmsh_4_11_0
  • gmsh_4_10_5
  • gmsh_4_10_4
  • gmsh_4_10_3
  • gmsh_4_10_2
  • gmsh_4_10_1
  • gmsh_4_10_0
  • gmsh_4_9_5
  • gmsh_4_9_4
  • gmsh_4_9_3
  • gmsh_4_9_2
  • gmsh_4_9_1
  • gmsh_4_9_0
41 results

t8.py

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;
    }