* A worker to concatenate other workers to create a zip file. * @param {Boolean} streamFiles `true` to stream the content of the files, * `false` to accumulate it. * @param {String} comment the comment to use. * @param {String} platform the platform to use, "UNIX" or "DOS". * @param {Function}
(streamFiles, comment, platform, encodeFileName)
| 319 | * @param {Function} encodeFileName the function to encode file names and comments. |
| 320 | */ |
| 321 | function ZipFileWorker(streamFiles, comment, platform, encodeFileName) { |
| 322 | GenericWorker.call(this, "ZipFileWorker"); |
| 323 | // The number of bytes written so far. This doesn't count accumulated chunks. |
| 324 | this.bytesWritten = 0; |
| 325 | // The comment of the zip file |
| 326 | this.zipComment = comment; |
| 327 | // The platform "generating" the zip file. |
| 328 | this.zipPlatform = platform; |
| 329 | // the function to encode file names and comments. |
| 330 | this.encodeFileName = encodeFileName; |
| 331 | // Should we stream the content of the files ? |
| 332 | this.streamFiles = streamFiles; |
| 333 | // If `streamFiles` is false, we will need to accumulate the content of the |
| 334 | // files to calculate sizes / crc32 (and write them *before* the content). |
| 335 | // This boolean indicates if we are accumulating chunks (it will change a lot |
| 336 | // during the lifetime of this worker). |
| 337 | this.accumulate = false; |
| 338 | // The buffer receiving chunks when accumulating content. |
| 339 | this.contentBuffer = []; |
| 340 | // The list of generated directory records. |
| 341 | this.dirRecords = []; |
| 342 | // The offset (in bytes) from the beginning of the zip file for the current source. |
| 343 | this.currentSourceOffset = 0; |
| 344 | // The total number of entries in this zip file. |
| 345 | this.entriesCount = 0; |
| 346 | // the name of the file currently being added, null when handling the end of the zip file. |
| 347 | // Used for the emitted metadata. |
| 348 | this.currentFile = null; |
| 349 | |
| 350 | |
| 351 | |
| 352 | this._sources = []; |
| 353 | } |
| 354 | utils.inherits(ZipFileWorker, GenericWorker); |
| 355 | |
| 356 | /** |
nothing calls this directly
no outgoing calls
no test coverage detected