【问题标题】:how compress file to zip with password use mozilla/zipwriter如何使用 mozilla/zipwriter 使用密码将文件压缩为 zip
【发布时间】:2019-07-31 02:36:36
【问题描述】:

使用mozilla/zipwriter 压缩文件时如何添加密码?

我用下面的代码,效果很好!

let zipFile = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("AChrom",Components.interfaces.nsIFile); 
zipFile.initWithPath(zipFile.path+"\\smad.zip"); 

const PR_RDONLY  = 0x01; 
const PR_WRONLY  = 0x02; 
const PR_RDWR  = 0x04; 
const PR_CREATE_FILE = 0x08; 
const PR_APPEND  = 0x10; 
const PR_TRUNCATE = 0x20; 
const PR_SYNC  = 0x40; 
const PR_EXCL  = 0x80; 

let zipWriter = Components.Constructor("@mozilla.org/zipwriter;1","nsIZipWriter"); 
let zipW = new zipWriter();
zipW.open(zipFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE);
zipW.addEntryFile(pathComponent.pop(),Components.interfaces.nsIZipWriter.COMPRESSION_DEFAULT,fileItem,false);
zipW.close();

但是如何添加密码呢?

【问题讨论】:

    标签: mozilla


    【解决方案1】:

    恐怕nsIZipWriter 似乎不支持密码。 IDL 定义或implementation 中未提及任何内容。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-17
      • 2017-05-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多