Parsing Zip files and saving it on writable path

Parsing Zip files and saving it on writable path
0.0 0

#1

Hello.
Is anybody know how to parse zip archive using jsb for native platforms or I need to create my own js binding.
I use this function to parse it on c++:

        ZipFile *zFile = ZipFile::createWithBuffer(&buffer->front(), buffer->size());
        if(!zFile)
        {
           log("zip file corrupt");
        }

        string fileName = zFile->getFirstFilename();
        string file = fileName;

        ssize_t fileSize;
        unsigned char* data = zFile->getFileData(fileName, &fileSize);

        bool isTemporary;
        while (data != nullptr)
        {

           isTemporary = isHaveFormat(file, "__MACOSX") || isHaveFormat(file, "/.DS_");
           if(!isTemporary)
           {
               folderName = contentVersionStruct->getType();
               if(folderName == "Armature")
               {
                   folderName = !isHaveFormat(fileName,".png") && !isHaveFormat(fileName, ".plist") ? "Armature" : "Atlas";
               }
               filePath = globalPath + folderName + "/" + file;
               if(fileSize != 0)
               {
                   FILE* asset = fopen(filePath.c_str(), "wb");
                   if (asset)
                   {
                       fwrite(data, 1, fileSize, asset);
                       fclose(asset);
                   }
               }
               else
               {
                   checkDirectory(filePath);
               }
           }
           free(data);
           fileName = zFile->getNextFilename();
           file = fileName;

           data = zFile->getFileData(fileName, &fileSize);
        }
    }
    else
    {
        folderName = contentVersionStruct->getType();
        filePath = globalPath + folderName + "/TileMap.json";
        FILE * asset = fopen(filePath.c_str(), "wb");
        if (asset)
        {
            fwrite(&(buffer->front()), 1, buffer->size(), asset);
            fclose(asset);
        }
    }

If I bind it how to convert javascript string to void* buffer in binding?