load.js 849 B

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. var base64 = require('./base64');
  3. var ZipEntries = require('./zipEntries');
  4. module.exports = function(data, options) {
  5. var files, zipEntries, i, input;
  6. options = options || {};
  7. if (options.base64) {
  8. data = base64.decode(data);
  9. }
  10. zipEntries = new ZipEntries(data, options);
  11. files = zipEntries.files;
  12. for (i = 0; i < files.length; i++) {
  13. input = files[i];
  14. this.file(input.fileName, input.decompressed, {
  15. binary: true,
  16. optimizedBinaryString: true,
  17. date: input.date,
  18. dir: input.dir,
  19. comment : input.fileComment.length ? input.fileComment : null,
  20. createFolders: options.createFolders
  21. });
  22. }
  23. if (zipEntries.zipComment.length) {
  24. this.comment = zipEntries.zipComment;
  25. }
  26. return this;
  27. };