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

重庆网站外包重庆网站建设冒号

重庆网站外包,重庆网站建设冒号,做3个网站需要多大的服务器,营口规划建设局网站zlib库可在git上自己clone下来然后使用cmake工具生成解决方案#xff0c;编译、生成zlib二进制文件。然后将zlib库引入项目#xff1a; //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::vectorZipperFileInfo 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::vectorZipperFileInfo 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::vectorZipperFileInfo vecZipperFiles, gzFile gzOut) {int nFileCount vecZipperFiles.size();gzwrite(gzOut, reinterpret_castconst void*(nFileCount), 4);gzwrite(gzOut, reinterpret_castconst 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::vectorZipperFileInfo 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_castsize_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.w-s-a.com/news/255294/

相关文章:

  • 二级网站域名长沙企业关键词优化服务质量
  • 在家有电脑怎么做网站wordpress 入门主题
  • 什邡建设局网站sem推广是什么意思
  • 西安分类信息网站网站敏感关键词
  • 黑彩网站怎么做建设网站费用分析
  • 网站关键词选取的步骤和方法小程序商城哪家好排行榜
  • 儿童产品网站建设网站建设优化排名推广
  • 做网站的硬件无锡招标网官方网站
  • 做推送好用的网站合肥网站推广培训
  • 网站开发团队简介贵阳双龙区建设局网站
  • 新乡做网站公司哪家好wordpress侧边栏文件
  • 小白建站怎么撤销网站备案
  • 哪个网站做调查问卷赚钱短视频制作神器
  • 上海企业响应式网站建设推荐汕头网络优化排名
  • 怎么建立公司网站平台怎么将网站做成公司官网
  • 培训学校网站怎样快速建设网站模板
  • 建设电子商务网站论文云服务器安装wordpress
  • 做展板好的网站学校的网站开发过程
  • 宁波搭建网站价格西部数码网站正在建设中是什么意思
  • 吉林省建设项目招标网站苏州网络推广定制
  • 网站域名所有权证明引流推广接单
  • 做网站百度百科孟州网站建设
  • 服务网站建设企业广州模板建站系统
  • 怎么做属于自己的免费网站浏览器游戏网址
  • 上海城乡住房建设厅网站西安网站推广慧创科技
  • 做策划网站推广怎么写简历互联网公司手机网站
  • 怎么做宣传网站网站建设采购项目合同书
  • 网站的空间和域名备案做网站要会写什么
  • wap 网站源码企业网站被转做非法用途
  • 下载网站模板怎么使用做物流网站的公司