我可以使用 wxwidgets 读取 zip 存档吗?

Can I read a zip archive using wxwidgets?

我想读取 zip 存档中的 xml 文件或文本文件,而无需将其从存档中解压缩。我可以不从 zip 存档中提取它而直接执行吗?

可以,wxZipInputStream 应该就是您要找的。

wxZipInputStream zip(in);

            while (entry.reset(zip.GetNextEntry()), entry.get() != NULL) {
                wxString name = entry->GetName();
                name = strPageName.BeforeLast('\') + wxFileName::GetPathSeparator() + name;

                    zip.OpenEntry(*entry.get());

                    wxFileOutputStream file(name);

                    if (!file) {
                    wxLogError(_T("Can not create file '") + name + _T("'."));
                    break;
                    }   

                    zip.Read(file); 

我尝试使用 wxZipInputStream。是的,我可以在从存档中提取文件后读取文件。我想知道我是否可以在不从 zip 存档中提取的情况下读取这些文件。

wxFileSystem::AddHandler(new wxZipFSHandler);

wxFileSystem fs;
wxFSFile *zip = fs.OpenFile( "d:\test.zip#zip:test.txt");
if(zip!=NULL)
{
  wxInputStream *in = zip->GetStream();
  if ( in != NULL )
  {
    wxFileOutputStream out( "d:\testout.txt" );
    out.Write(*in);
    out.Close();
  }
  delete zip;
}

是的,我们可以直接从存档中读取 zip 文件。以上为示例代码