axmolengine / axmol

Axmol Engine – A Multi-platform Engine for Desktop, XBOX (UWP) and Mobile games. (A fork of Cocos2d-x-4.0)
https://axmol.dev
MIT License
922 stars 205 forks source link

ZipUtils class - How to use it (need examples) #2139

Closed asnagni closed 2 months ago

asnagni commented 2 months ago

Hi, I'm trying to use the class ax::ZipUtils . The goal is to unzip a file that I dowloaded on the device (iOS & Android). Unfortunately there is no example or documentation on how to use this class. Do anyone have an idea on how to use this class? I do not want to install an extra library if Axmol has one that I can use.

Thank you, Stay safe

  1. download a Zip file on the device
  2. Try to unzip it
rh101 commented 2 months ago

You should use ax::ZipFile. The methods in that class are pretty self-explanatory.

Simple example:

const auto zipFile = std::unique_ptr<ax::ZipFile>(ax::ZipFile::createFromFile(zipFilePath));
if (zipFile && zipFile->fileExists("data.json"sv))
{
    std::string s;
    ax::ResizableBufferAdapter buf(&s);
    if (zipFile->getFileData("data.json"sv, &buf))
    {
        // do something with the data
    }
}
asnagni commented 2 months ago

Hi @rh101 , Thank you for the info. I was looking at the wrong class apparently. Thank you for the info and the example, I do appreciate.

Stay safe.

rh101 commented 2 months ago

Hi @rh101 , Thank you for the info. I was looking at the wrong class apparently. Thank you for the info and the example, I do appreciate.

Stay safe.

No problem. Please do not forget to close this issue, and any others you have created that should be closed.