当前位置: 首页 > news >正文

电商网站用php做的吗酒泉网站建设哪家好

电商网站用php做的吗,酒泉网站建设哪家好,军队工程建设项目招投标网站,福步外贸zlib库可在git上自己clone下来然后使用cmake工具生成解决方案,编译、生成zlib二进制文件。然后将zlib库引入项目: //zlib库支持 #include "../zlib/include/zlib.h" #ifdef _DEBUG #pragma comment(lib, "../zlib/lib/zlibd.lib") …

zlib库可在git上自己clone下来然后使用cmake工具生成解决方案,编译、生成zlib二进制文件。然后将zlib库引入项目:

//zlib库支持
#include "../zlib/include/zlib.h"
#ifdef _DEBUG
#pragma comment(lib, "../zlib/lib/zlibd.lib")
#else
#pragma comment(lib, "../zlib/lib/zlib.lib")
#endif

定义一个文件结构

typedef struct tagZipperFileInfo
{char m_szLocalPath[MAX_PATH];char m_szRootPath[MAX_PATH];char m_szFileName[MAX_PATH];size_t m_FileSize;
}ZipperFileInfo;

压缩文件相关:

/*
*	strFolder	需要被压缩的文件夹
*	strOut		保存的文件
*/
void CompressFolder(std::string& strFolder, std::string& strOut)
{//创建压缩的目标文件std::ofstream dest(strOut, std::ios::binary | std::ios::trunc);if (!dest.is_open()) {//errorreturn;}dest.close();std::vector<ZipperFileInfo> vecZipperFiles;//遍历文件夹下的所有文件OperateFolder(strFolder, strFolder, vecZipperFiles);//压缩文件gzFile gzOut = gzopen(strOut.c_str(), "wb");CompressFiles(vecZipperFiles, gzOut);gzclose(gzOut);
}
void OperateFolder(std::string& strFolder, std::string& strRoot, std::vector<ZipperFileInfo>& vecZipperFiles)
{std::string searchPath = strFolder + "\\*";WIN32_FIND_DATAA findData;HANDLE hFind = FindFirstFileA(searchPath.c_str(), &findData);if (hFind == INVALID_HANDLE_VALUE) {//errorreturn;}do {if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {if (strcmp(findData.cFileName, ".") != 0 && strcmp(findData.cFileName, "..") != 0) {std::string subFolderPath = strFolder + "\\" + findData.cFileName;OperateFolder(subFolderPath, strRoot, vecZipperFiles);}}else {std::string strLocalPath = strFolder + "\\" + findData.cFileName;std::string strFileRootPath = strFolder;std::string strFileName = findData.cFileName;//需要根据strRoot分割出来需要压缩文件的相对路径名std::string strTempPath;size_t start = strFileRootPath.find(strRoot);if (start == std::string::npos)strTempPath = strFileRootPath; // 如果找不到根路径,则返回完整路径else{if (strFileRootPath == strRoot)strTempPath = strFileRootPath.substr(start + strRoot.length());elsestrTempPath = strFileRootPath.substr(start + strRoot.length() + 1);}ZipperFileInfo zipperFile;memcpy(zipperFile.m_szRootPath, strTempPath.c_str(), MAX_PATH);memcpy(zipperFile.m_szLocalPath, strLocalPath.c_str(), MAX_PATH);memcpy(zipperFile.m_szFileName, strFileName.c_str(), MAX_PATH);//计算文件大小std::ifstream in(strLocalPath, std::ios::binary | std::ios::ate);size_t fileSize = in.tellg();in.seekg(0);in.close();zipperFile.m_FileSize = fileSize;vecZipperFiles.push_back(zipperFile);}} while (FindNextFileA(hFind, &findData) != 0);FindClose(hFind);
}

压缩文件:

void CompressFiles(std::vector<ZipperFileInfo>& vecZipperFiles, gzFile& gzOut)
{int nFileCount = vecZipperFiles.size();gzwrite(gzOut, reinterpret_cast<const void*>(&nFileCount), 4);gzwrite(gzOut, reinterpret_cast<const void*>(vecZipperFiles.data()), vecZipperFiles.size() * sizeof(ZipperFileInfo));//再往压缩文件中写入需要压缩为文件内容for (int i = 0; i < vecZipperFiles.size(); i++){std::string strLocalPath = vecZipperFiles[i].m_szLocalPath;std::ifstream infile(strLocalPath, std::ios::binary);char buffer[4096];while (infile){infile.read(buffer, sizeof(buffer));auto bytes = infile.gcount();if (bytes > 0){//写入目标压缩文件gzwrite(gzOut, buffer, bytes);}}infile.close();}
}

文件解压相关:

//strFilePath 压缩文件路径
void DecompressFiles(std::string& strFilePath)
{gzFile gzin = gzopen(strFilePath.c_str(), "rb");if (!gzin) return; //open errorint nFileCount = 0;gzread(gzin, &nFileCount, 4); //读取压缩的文件数量// 读取文件列表信息std::vector<ZipperFileInfo> vecZipperFiles;ZipperFileInfo zipperFile;for (int i = 0; i < nFileCount; i++){if (gzread(gzin, &zipperFile, sizeof(ZipperFileInfo)) == sizeof(ZipperFileInfo))vecZipperFiles.push_back(zipperFile);}SStringW sstrAppPath = CGlobalUnits::GetInstance()->m_sstrAppPath;std::string strAppPath = S_CW2A(sstrAppPath);//先创建个输出目录size_t szPos = strFilePath.find_last_of("\\");if (szPos != std::string::npos){std::string strTmp = strFilePath.substr(szPos + 1);//分解出namesize_t szName = strTmp.find_last_of(".");if (szName != std::string::npos){std::string strName = strTmp.substr(0, szName);strAppPath += strName;}}CreateDirectoryA(strAppPath.c_str(), NULL);//解压文件for (int i = 0; i < vecZipperFiles.size(); i++){ZipperFileInfo& info = vecZipperFiles[i];std::string strRoot = info.m_szRootPath;std::string strPath;if (strRoot == "")  //根目录下strPath = strAppPath + "\\" + info.m_szFileName;else{CreateFolder(strAppPath, strRoot);strPath = strAppPath + "\\" + strRoot + "\\" + info.m_szFileName;}std::ofstream outFile(strPath, std::ios::binary);if (!outFile) continue;  //error char buffer[4096];size_t fileSize = info.m_FileSize;while (fileSize > 0){size_t bytesToRead = std::min(static_cast<size_t>(4096), fileSize);int bytesRead = gzread(gzin, buffer, bytesToRead);if (bytesRead <= 0) break; //read erroroutFile.write(buffer, bytesRead);fileSize -= bytesRead;}outFile.close();}gzclose(gzin);
}

递归生成压缩文件中的目录结构:

/*
*	strRoot	解压缩的目标目录
*	strDir	压缩文件的相对路径
*/
void CreateFolder(std::string& strRoot, std::string& strDir)
{size_t szPos = strDir.find_first_of("\\");if (szPos != std::string::npos){std::string strName = strDir.substr(0, szPos);std::string strPath = strRoot + "\\" + strName;CreateDirectoryA(strPath.c_str(), NULL);std::string strSubName = strDir.substr(szPos + 1);std::string strTempRoot = strRoot + "\\" + strName;CreateFolder(strTempRoot, strSubName);}else{std::string strPath = strRoot + "\\" + strDir;CreateDirectoryA(strPath.c_str(), NULL);}
}
http://www.yayakq.cn/news/53904/

相关文章:

  • 建设网络强国征文什么是网站推广优化
  • 网站建设推广策划南通做网站优化
  • 成都网站设计公司排名注册安全工程师好考吗难度大吗
  • 网站框架搭建网站建设与思想阵地
  • 梧州网站开发阿里云安装wordpress数据库错误
  • 美仑美家具的网站谁做的网站建设合同 域名续期
  • 石家庄网站制作模板wordpress发的文章提示404
  • 如何拿高权重网站外链进行互换?教室在线设计网站
  • 赣州做公司网站wordpress 菜单 颜色
  • 个人的网站建设目标邢台人才网官网首页
  • 企梦网站建设优化前网站现状分析
  • 家居企业网站建设公司网上购物哪个商城好
  • 新型塑料建筑模板图片企业网站优化推广方法
  • 遵化建行网站礼泉做网站
  • 目前网站类型主要包括哪几种如何建设景区旅游网站
  • 网站开发专业都有哪些课程wordpress数组转字符串
  • 要做未来科技的网站怎么做服务号微网站怎么做的
  • 门户网站用虚拟主机百度收录查询api
  • 做今网站数据分析师报考条件
  • 网站开发 xmind野狼seo团队
  • asp网站建设实录源码html5网站建设
  • 汕尾建设网站网站开发报价文件
  • 抽奖的网站怎么做网站建设logo要什么格式
  • 怎么做自己网站的API国内人做韩国网站一般都卖什么东西
  • iis通过地址访问不了网站html网站标签
  • 西安网站建设云阔网络网站建设网站软件
  • 电子商务网站建设方案的总结wordpress修改文章阅读量
  • 漳州做网站配博大钱少a室内设计公司及效果图
  • 介休做网站东莞做网站的公司有哪些
  • 景观设计网站推荐网站建设的实训体会