Discussion of article "Handling ZIP Archives in Pure MQL5" - page 3

 

Script

#include <Zip\Zip.mqh>
CZip Zip;


void OnStart()
  {
//---
   string pathdir = "DD\\";

   for(int yy2 = 2014; yy2 <= 2017; yy2++)
      {
         string FileArc = pathdir + "d" + IntegerToString(yy2) + ".zip";
         
         Print("--------------  ", FileArc);
         
         Print(FileArc, "   Zip.LoadZipFromFile= ", Zip.LoadZipFromFile(FileArc, 0) );
         
                    
         printf("Archive successfully loaded. Total files: "+(string)Zip.TotalElements());
         
         Print("Zip.UnpackZipArchive= ", Zip.UnpackZipArchive(pathdir + "H" + IntegerToString(yy2), 0) );

      }
  }
 
Dmytro Zelenskyy:

Here is another problem, if I need to unpack several archives in a loop, changing only the year in the name.

Only d2014.zip is unpacked and that's it.

Try clearing the archive after unpacking.

#include <Zip\Zip.mqh>
CZip Zip;


void OnStart()
  {
//---
   string pathdir = "DD\\";

   for(int yy2 = 2014; yy2 <= 2017; yy2++)
      {
         string FileArc = pathdir + "d" + IntegerToString(yy2) + ".zip";
         
         Print("--------------  ", FileArc);
         
         Print(FileArc, "   Zip.LoadZipFromFile= ", Zip.LoadZipFromFile(FileArc, 0) );
         
                    
         printf("Archive successfully loaded. Total files: "+(string)Zip.TotalElements());
         
         Print("Zip.UnpackZipArchive= ", Zip.UnpackZipArchive(pathdir + "H" + IntegerToString(yy2), 0) );
         Zip.Clear();

      }
  }
 

YES!!!

I'm glad that I realised it myself and decided to write a solution :))),

and there is a prompt reply :))))

Thank you!

 

credit to the author for the library !!!

results for comparison:


1. .bin - data is written by resetting to binary format one by one data from structure and class objects

2. .dat - data first converted to BYTE array, then dumped to disc as binary data

3. .zip - method 2 + software compression

log of processing stages of creation, writing and reading without compression and with compression:

after each reading of data from the files, a check is made with the original data for correctness, no errors are detected ))
 
The library "floated" with the new build 1816 (( Apparently they removed a bug in union and now it frowns on the use of a structure object with a constructor in union.
 
Konstantin:
The library "floated" with the new build 1816 (( Apparently they removed a bug in union and now it frowns on the use of a structure object with a constructor in union

I recommend to refuse using a constructor for structures participating in union

Instead of constructors, it is better to use Initialise/Init function.

For our part, we will someday add the ability to use structures with constructors in union, provided that union has an explicit/user constructor. So, the way and order of constructing will be on the user/creator's conscience.

But we can't say when (Developer Response)
 
Rashid Umarov:

I recommend not using constructor for structures participating in union

Instead of constructors, it is better to use Initialise/Init function.

For our part, we will someday add the ability to use structures with constructors in union, provided that union has an explicit/user-defined constructor. So, the way and order of constructing will be on the user/creator's conscience.

But we can't say when (Developer response).

there is no sense to change it, I have already sent to the developer a redesigned class just without constructors in structures, just added Init method for initialisation of structures and that's all, you just fix the problem with certificates under Linux, because it's so incomplete ))

 
Corrections to the library header file.
Files:
ZipHeader.mqh  13 kb
 
Rashid Umarov:

I recommend not using constructor for structures participating in union

Instead of constructors, it is better to use Initialise/Init function.

For our part, we will someday add the ability to use structures with constructors in union, provided that union has an explicit/user-defined constructor. So, the way and order of constructing will be on the user/creator's conscience.

But we can't say when we will be able to do it (Developer response).

I think you are clearly in the wrong business. There was an explicit casting of structures - then for some reason they removed it and decided that "type pun" union is somehow better than explicit casting. Then the structure constructor started to interfere with union. They banned it too. Now you are planning to allow it again... But your actions make many codes in CodeBase not compile now. But these innovations do not solve any problems.

 
CZip source code corrected for compatibility with newer versions of the compiler. Updates will be available after verification by a moderator.