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

网站建设 语言wordpress 最大上传文件大小

网站建设 语言,wordpress 最大上传文件大小,南京宣传片公司有哪些,网站标题图片怎么做最近#xff0c;在处理文件压缩的任务时#xff0c;我遇到了一个有趣的问题。使用Minizip库进行文件压缩后#xff0c;在解压过程中收到了一个关于头部错误的警告。尽管这个警告看似令人担忧#xff0c;但解压操作最终仍然能够成功完成文件的解压。这引发了我的…最近在处理文件压缩的任务时我遇到了一个有趣的问题。使用Minizip库进行文件压缩后在解压过程中收到了一个关于头部错误的警告。尽管这个警告看似令人担忧但解压操作最终仍然能够成功完成文件的解压。这引发了我的好奇心我决定深入探究这个问题。 首先想分享一下我使用的压缩代码 bool XXXCompressor::compressData(const std::string input_file_name, const std::string output_file_name) {// 打开ZIP文件如果不存在则创建zipFile zf zipOpen(output_file_name.c_str(), APPEND_STATUS_CREATE);if (zf NULL){LOGE(Error opening ZIP file. output_file_name: %s, output_file_name.c_str());return false;}// 打开要压缩的文件FILE *file_to_zip fopen(input_file_name.c_str(), rb);if (!file_to_zip){LOGE(Error opening file to zip. input_file_name: %s, input_file_name.c_str());zipClose(zf, NULL);return false;}// 定义ZIP条目zip_fileinfo zfi;memset(zfi, 0, sizeof(zfi));size_t found input_file_name.find_last_of(/\\);std::string filename_zip;if (found ! std::string::npos){filename_zip input_file_name.substr(found 1);filename_zip filename_zip .log;}// 打开ZIP中的新文件条目if (zipOpenNewFileInZip(zf, filename_zip.c_str(), zfi,NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION) ! ZIP_OK){LOGE(Error opening file in ZIP.);fclose(file_to_zip);zipClose(zf, NULL);return false;}// 读取文件内容并写入ZIP// char buffer[1024];memset(buffer, 0, sizeof(buffer));unsigned int len;while ((len fread(buffer, 1, sizeof(buffer), file_to_zip)) 0){if (zipWriteInFileInZip(zf, buffer, len) 0){LOGE(Error writing file in ZIP.);break;}}// 关闭ZIP中的文件条目if (zipCloseFileInZip(zf) ! ZIP_OK){LOGE(Error closing file in ZIP.);}// 关闭文件和ZIP文件fclose(file_to_zip);if (zipClose(zf, NULL) ! 0){LOGE(Error closing ZIP file.);}return true; // 压缩成功 } 这段代码在压缩文件时表现良好但在解压时却出现了一些不和谐的声音。如下图 经过一系列的测试和研究我发现这个“头部错误”的警告可能是由于Minizip在解压时对文件头部的某些预期与实际不符所导致的。 这种情况虽然并未影响到文件的最终解压结果但它确实引起了我对压缩过程可靠性的疑虑。 为了解决这个问题我查阅了Minizip的官方文档和社区讨论寻找是否有其他用户遇到类似问题的解决方案。发现缺失了filetime操作即 #ifdef _WIN32 # include direct.h # include io.h #else # include unistd.h # include utime.h # include sys/types.h # include sys/stat.h #endif#ifdef _WIN32#define USEWIN32IOAPI#include iowin32.h #endif #ifdef _WIN32 /* f: name of file to get info on, tmzip: return value: access,modification and creation times, dt: dostime */ static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {(void)tmzip;int ret 0;{FILETIME ftLocal;HANDLE hFind;WIN32_FIND_DATAA ff32;hFind FindFirstFileA(f,ff32);if (hFind ! INVALID_HANDLE_VALUE){FileTimeToLocalFileTime((ff32.ftLastWriteTime),ftLocal);FileTimeToDosDateTime(ftLocal,((LPWORD)dt)1,((LPWORD)dt)0);FindClose(hFind);ret 1;}}return ret; } #elif defined(__unix__) || defined(__unix) || defined(__APPLE__) /* f: name of file to get info on, tmzip: return value: access,modification and creation times, dt: dostime */ static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {(void)dt;int ret0;struct stat s; /* results of stat() */struct tm* filedate;time_t tm_t0;if (strcmp(f,-)!0){char name[MAXFILENAME1];size_t len strlen(f);if (len MAXFILENAME)len MAXFILENAME;strncpy(name, f,MAXFILENAME-1);/* strncpy doesnt append the trailing NULL, of the string is too long. */name[ MAXFILENAME ] \0;if (name[len - 1] /)name[len - 1] \0;/* not all systems allow stating a file with / appended */if (stat(name,s)0){tm_t s.st_mtime;ret 1;}}filedate localtime(tm_t);tmzip-tm_sec filedate-tm_sec;tmzip-tm_min filedate-tm_min;tmzip-tm_hour filedate-tm_hour;tmzip-tm_mday filedate-tm_mday;tmzip-tm_mon filedate-tm_mon ;tmzip-tm_year filedate-tm_year;return ret; } #else /* f: name of file to get info on, tmzip: return value: access,modification and creation times, dt: dostime */ static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {(void)f;(void)tmzip;(void)dt;return 0; } #endif 之后将下面这行语句加入压缩前的代码中即可 filetime(filename_zip.c_str(),zfi.tmz_date,zfi.dosDate); 在接下来的段落中我将详细分享我的解决方案和一些额外的心得体会希望能帮助到遇到类似问题的朋友们。
http://www.hkea.cn/news/14258529/

相关文章:

  • 网站注册页面模板下载深圳市市场监督管理局官网
  • 天津招投标天津建设工程信息网广安网站seo
  • 长春火车站最新消息网站建设总结材料
  • 沈阳正规制作网站公司吗怎样做单页微信网站连接
  • 企业建筑网站有哪些类型有哪些免费推广网站大全网
  • 唐山做网站口碑好的wordpress4.9.8主题
  • 凡科网站建设的技巧宣城网站推广
  • 手机有办法做网站吗中国建设银行财付通网站
  • 网站广告尺寸天河区住房和建设水务局官方网站
  • 小程序制作网站怎么使用网站程序
  • 长春建网站一般多少钱网站商城例子下载
  • 上海网站建设网页制作你却沪佳装饰门店地址
  • ui设计网站模板网站建设前期规划方案范文
  • 做网站需要域名手机在线做ppt的网站
  • intitle 网站建设wordpress 不提示更新
  • 工程项目网站wordpress可视化编辑器插件
  • 导航站wordpress广告费内包括网站建设
  • 有什么免费建站网站成都网站制作成都网站制作
  • 岫岩做网站网站备案后会被注销吗
  • 建设监理收录网站抖音seo教程
  • 网站免费制作教程免费刷seo
  • 网站设计酷站学校网站模板 dedecms
  • 网站开发工具中三剑客包括网络营销推广渠道有哪些
  • 林州网站建设公司宁夏建设厅官方网站
  • 眼镜商城网站建设方案京东app下载官网免费下载
  • 中国工程建设造价管理协会网站交换链接营销成功案例
  • 杨浦做网站电子商务网站有哪些类型
  • 襄阳购物网站开发设计php wap网站实现滑动式数据分页
  • 石林彝族网站建设响应式网站模板 视差
  • 广州做购物网站网站建设中 倒计时