使用 XZIP 打开 C++ 中的 zip 文件
Opening a zip file in C++ with XZIP
在我当前的项目中,我必须转到某个用户输入的目录,打开该目录并读取该目录中以W开头的所有zip文件。我正在尝试使用 XZIP 库打开 ZIP 文件,但我肯定做错了什么。我很困惑是使用 UnzipItem 还是 Openzip 来打开 zip 文件并解析其内容。(每个zip文件都包含一些.jpg文件,我必须将这些文件复制到另一个位置,但这是项目的第二部分)
我真的很感激一些帮助,谢谢:)
这是我的代码-
#include "StdAfx.h"
#include "srcXZip.h"
#include "srcXUnzip.h"
#include <string>
#include <fstream>
#include <iostream>
#include <sstream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <fstream>
#include <iostream>
#include <string>
#include "srcdirent.h"
#include <sys/stat.h>
#include <sys/types.h>
#include <windows.h>
int main()
{
std::ifstream fin;
std::string dir, filepath;
int num;
DIR *dp;
struct dirent *dirp;
struct stat filestat;
std::string filename;
std::string userInput;
std::cout << " Input dir to get files from : ";
getline( std::cin, dir ); // gets everything the user
dp = opendir( dir.c_str() );
if (dp == NULL)
{
std::cout << "Error opening " << dir << std::endl;
}
char test[2];
while ((dirp = readdir( dp )) != NULL)
{ // printf(" inside the directory ");
filepath = dir+"/" + dirp->d_name;
filename =dirp->d_name;
test[0]=filename[0];
test[1]=' ';
if ( test[0]=='W')
{ HZIP* z;
DWORD File_name = std::strtoul(filename.c_str(), NULL, 16);
OpenZip(z,0,File_name);
}
}
return 0;
}
从文档中,我会说您首先需要调用OpenZip
以获取句柄,并且使用该句柄调用UzipItem
您从FindZipItem
获得的项目 ID .
我所拥有的只是文档:
标志 - 表示用法,见下文; 对于文件,这将ZIP_FILENAME
所以我猜是这样的:auto handle = OpenZip("file.zip", 0, ZIP_FILENAME);
相关文章:
- 捕获标准输出以压缩并使用 CTRL-C 中断会给出损坏的 zip 文件
- 使用 Poco::Zip 将文件附加到现有 zip 文件
- 无法在 Cocos2dx 中使用受密码保护的 zip 文件
- 如何使用 Poco::ZIP 压缩/解压缩 zip 文件
- cpp libcurl 在 HTTP post 调用中发送 zip 文件,而不使用 multipart\form-da
- 使用 libzip 打开 zip 文件时遇到问题
- 如何使用 "DFLT-X" 方法编写 Zip 文件
- C++ 使用Powershell命令提取zip文件
- 如何在 mfc c++ 中流式传输.zip文件夹的二进制表示形式
- 如何解决系统.Zip.TZipFile.ExtractAll无法从.zip文件中提取所有数据的问题
- 需要正则表达式来提取zip文件中的所有文件
- 只读二进制zip文件的一部分
- 如何使用 C/C++检查 ZIP 文件(Office Open XML 文件)的完整性
- 如何使用 zlib.h 库将.zip文件解压缩到文件夹中
- 如何使用 zlib 在 zip 文件中添加/删除特定文件
- C++将文件权限添加到 zip 文件
- zip文件到缓冲区c++
- 从网络共享中部分提取zip文件
- 从zip文件中提取文件夹
- 使用 XZIP 打开 C++ 中的 zip 文件