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

 
Good day, Vasily! The situation is as follows: I download a book of orders-positions from OANDA, they arrive packed in API v.2, when I try to unpack them using CZip, I get the following message: "There was an error of archive processing at the moment of its loading: ZIP_ERROR_BAD_FORMAT_ZIP". I don't know exactly what it is packed with, but WinZip unfolds the received file. The files are attached just in case.
Files:
oanda_data.txt  85 kb
 
The archive file could not be attached, if you need it I will send it to your mail.
 
I downloaded the zip, there are several files in the archive. I try to unzip them and nothing works. I'm looking at the code and I come up with this fragment:
//+------------------------------------------------------------------+
//|| Unpack current zip content and save it as file on disk. ||
//+------------------------------------------------------------------+
bool CZipContent::UnpackOnDisk(string folder, int file_common)
{
   return false;   
}


I understand that unzipping doesn't work ?
 
Alexey Oreshkin:
I look at the code and come to this fragment:

i.e. I understand correctly that unzipping does not work ?

Look at the code in debug mode, you will come to the right fragment. Unzipping works - I use it every day.

 
Alexey Oreshkin:
I downloaded the zip, there are several files in the archive. I'm trying to unzip and nothing works.I look at the code and come to this fragment:
so I understand correctly that unzipping does not work ?

No, it's not. Look carefully, UnpackOnDisk is a virtual method. It has no implementation in the abstract class Content. Unfortunately, MQL does not allow you to create virtual methods without implementation, so you have to put stoppers like the one you found. The real work of saving a file to disc is done by CZipFile::UnpackOnDisk and CZipDirectory::UnpackOnDisk. This is because creating a directory and a file on disc are different operations, so they are done by different methods.

 
M24:
The archive file could not be attached, if you need it I will send it to your mail.

That's actually the most important thing. First, make sure you are using the latest version of CZip and try unpacking again.

 
fxsaber:

See the code in debug mode, you will get to the necessary piece. Unzipping works - I use it every day.

then what am I doing wrong. Here's my code:

   Zip.LoadZipFromFile("info.zip",FILE_COMMON);
   Zip.UnpackZipArchive("",FILE_COMMON);

I expect to see everything unzipped in the public folder, but it's empty. I don't need anything else. There is info.zip in the public folder.

 
Alexey Oreshkin:

then what am I doing wrong. Here is my code:

I expect to see everything unzipped in the public folder, but it's empty. I don't need anything else. There is info.zip in the public folder.

You'll have to specify the folder, because double quotes work with an error.

 
fxsaber:

You will have to specify a folder, as double quotes work with an error.

Honestly, nothing has changed:

   Zip.LoadZipFromFile("info.zip",FILE_COMMON);
   Zip.UnpackZipArchive("Test",FILE_COMMON);

the result is also null.


p.s. I took an example from the article

   string cookie,headers;
   string mql_url="https://www.mql5.com/en/code/download/9";
   int timeout=5000;
   uchar data[],zip_array[];
   if(!WebRequest("GET",mql_url,cookie,NULL,timeout,data,0,zip_array,headers))
     {
      printf("Unable to download ZIP archive from "+mql_url+". Check request and permissions EA.");
      return;
     }
   if(!Zip.CreateFromCharArray(zip_array))
     {
      printf("Loaded bad ZIP archive. Check results array.");
      return;
     }
   printf("Archive successfully loaded. Total files: "+(string)Zip.TotalElements());
   Zip.UnpackZipArchive("Alligator",FILE_COMMON);

I changed the url (in the terminal settings I allowed access) and that's all, the result is also zero. I thought I would transfer the parser from Sharp to here and I guess not. So much effort to just unzip the file and nothing (

 
Alexey Oreshkin:

Honestly nothing has changed:

the result is also nil.

#include <Zip\Zip.mqh> // https://www.mql5.com/en/articles/1971

void OnStart()
{
  CZip Zip;

  Zip.LoadZipFromFile("Test.zip", FILE_COMMON);
  Zip.UnpackZipArchive("Temp", FILE_COMMON);
}
Files:
Test.zip  151 kb