Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

zip.js 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /**
  2. * ZIP Format Plugin
  3. *
  4. * @module plugins/zip
  5. * @license [MIT]{@link https://github.com/archiverjs/node-archiver/blob/master/LICENSE}
  6. * @copyright (c) 2012-2014 Chris Talkington, contributors.
  7. */
  8. var engine = require('zip-stream');
  9. var util = require('archiver-utils');
  10. /**
  11. * @constructor
  12. * @param {ZipOptions} [options]
  13. * @param {String} [options.comment] Sets the zip archive comment.
  14. * @param {Boolean} [options.forceLocalTime=false] Forces the archive to contain local file times instead of UTC.
  15. * @param {Boolean} [options.forceZip64=false] Forces the archive to contain ZIP64 headers.
  16. * @param {Boolean} [options.namePrependSlash=false] Prepends a forward slash to archive file paths.
  17. * @param {Boolean} [options.store=false] Sets the compression method to STORE.
  18. * @param {Object} [options.zlib] Passed to [zlib]{@link https://nodejs.org/api/zlib.html#zlib_class_options}
  19. */
  20. var Zip = function(options) {
  21. if (!(this instanceof Zip)) {
  22. return new Zip(options);
  23. }
  24. options = this.options = util.defaults(options, {
  25. comment: '',
  26. forceUTC: false,
  27. namePrependSlash: false,
  28. store: false
  29. });
  30. this.supports = {
  31. directory: true,
  32. symlink: true
  33. };
  34. this.engine = new engine(options);
  35. };
  36. /**
  37. * @param {(Buffer|Stream)} source
  38. * @param {ZipEntryData} data
  39. * @param {String} data.name Sets the entry name including internal path.
  40. * @param {(String|Date)} [data.date=NOW()] Sets the entry date.
  41. * @param {Number} [data.mode=D:0755/F:0644] Sets the entry permissions.
  42. * @param {String} [data.prefix] Sets a path prefix for the entry name. Useful
  43. * when working with methods like `directory` or `glob`.
  44. * @param {fs.Stats} [data.stats] Sets the fs stat data for this entry allowing
  45. * for reduction of fs stat calls when stat data is already known.
  46. * @param {Boolean} [data.store=ZipOptions.store] Sets the compression method to STORE.
  47. * @param {Function} callback
  48. * @return void
  49. */
  50. Zip.prototype.append = function(source, data, callback) {
  51. this.engine.entry(source, data, callback);
  52. };
  53. /**
  54. * @return void
  55. */
  56. Zip.prototype.finalize = function() {
  57. this.engine.finalize();
  58. };
  59. /**
  60. * @return this.engine
  61. */
  62. Zip.prototype.on = function() {
  63. return this.engine.on.apply(this.engine, arguments);
  64. };
  65. /**
  66. * @return this.engine
  67. */
  68. Zip.prototype.pipe = function() {
  69. return this.engine.pipe.apply(this.engine, arguments);
  70. };
  71. /**
  72. * @return this.engine
  73. */
  74. Zip.prototype.unpipe = function() {
  75. return this.engine.unpipe.apply(this.engine, arguments);
  76. };
  77. module.exports = Zip;
  78. /**
  79. * @typedef {Object} ZipOptions
  80. * @global
  81. * @property {String} [comment] Sets the zip archive comment.
  82. * @property {Boolean} [forceLocalTime=false] Forces the archive to contain local file times instead of UTC.
  83. * @property {Boolean} [forceZip64=false] Forces the archive to contain ZIP64 headers.
  84. * @prpperty {Boolean} [namePrependSlash=false] Prepends a forward slash to archive file paths.
  85. * @property {Boolean} [store=false] Sets the compression method to STORE.
  86. * @property {Object} [zlib] Passed to [zlib]{@link https://nodejs.org/api/zlib.html#zlib_class_options}
  87. * to control compression.
  88. * @property {*} [*] See [zip-stream]{@link https://archiverjs.com/zip-stream/ZipStream.html} documentation for current list of properties.
  89. */
  90. /**
  91. * @typedef {Object} ZipEntryData
  92. * @global
  93. * @property {String} name Sets the entry name including internal path.
  94. * @property {(String|Date)} [date=NOW()] Sets the entry date.
  95. * @property {Number} [mode=D:0755/F:0644] Sets the entry permissions.
  96. * @property {Boolean} [namePrependSlash=ZipOptions.namePrependSlash] Prepends a forward slash to archive file paths.
  97. * @property {String} [prefix] Sets a path prefix for the entry name. Useful
  98. * when working with methods like `directory` or `glob`.
  99. * @property {fs.Stats} [stats] Sets the fs stat data for this entry allowing
  100. * for reduction of fs stat calls when stat data is already known.
  101. * @property {Boolean} [store=ZipOptions.store] Sets the compression method to STORE.
  102. */
  103. /**
  104. * ZipStream Module
  105. * @external ZipStream
  106. * @see {@link https://www.archiverjs.com/zip-stream/ZipStream.html}
  107. */