blob: 64d25c34ac7f8635bff324decd77c735b6c11e17 [file] [log] [blame]
kumaran.m3b4814a2020-05-01 19:48:54 +05301/*
2 Copyright 2020 TATA ELXSI
3
4 Licensed under the Apache License, Version 2.0 (the 'License');
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15
16 Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in)
17 */
18var Tar =
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +053019/******/ (function (modules) { // webpackBootstrap
kumaran.m3b4814a2020-05-01 19:48:54 +053020/******/ // The module cache
21/******/ var installedModules = {};
22/******/
23/******/ // The require function
24/******/ function __webpack_require__(moduleId) {
25/******/
26/******/ // Check if module is in cache
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +053027/******/ if (installedModules[moduleId]) {
kumaran.m3b4814a2020-05-01 19:48:54 +053028/******/ return installedModules[moduleId].exports;
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +053029 /******/
30}
kumaran.m3b4814a2020-05-01 19:48:54 +053031/******/ // Create a new module (and put it into the cache)
32/******/ var module = installedModules[moduleId] = {
33/******/ i: moduleId,
34/******/ l: false,
35/******/ exports: {}
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +053036 /******/
37};
kumaran.m3b4814a2020-05-01 19:48:54 +053038/******/
39/******/ // Execute the module function
40/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
41/******/
42/******/ // Flag the module as loaded
43/******/ module.l = true;
44/******/
45/******/ // Return the exports of the module
46/******/ return module.exports;
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +053047 /******/
48}
kumaran.m3b4814a2020-05-01 19:48:54 +053049/******/
50/******/
51/******/ // expose the modules object (__webpack_modules__)
52/******/ __webpack_require__.m = modules;
53/******/
54/******/ // expose the module cache
55/******/ __webpack_require__.c = installedModules;
56/******/
57/******/ // identity function for calling harmony imports with the correct context
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +053058/******/ __webpack_require__.i = function (value) { return value; };
kumaran.m3b4814a2020-05-01 19:48:54 +053059/******/
60/******/ // define getter function for harmony exports
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +053061/******/ __webpack_require__.d = function (exports, name, getter) {
62/******/ if (!__webpack_require__.o(exports, name)) {
kumaran.m3b4814a2020-05-01 19:48:54 +053063/******/ Object.defineProperty(exports, name, {
64/******/ configurable: false,
65/******/ enumerable: true,
66/******/ get: getter
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +053067 /******/
68});
69 /******/
70}
71 /******/
72};
kumaran.m3b4814a2020-05-01 19:48:54 +053073/******/
74/******/ // getDefaultExport function for compatibility with non-harmony modules
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +053075/******/ __webpack_require__.n = function (module) {
kumaran.m3b4814a2020-05-01 19:48:54 +053076/******/ var getter = module && module.__esModule ?
77/******/ function getDefault() { return module['default']; } :
78/******/ function getModuleExports() { return module; };
79/******/ __webpack_require__.d(getter, 'a', getter);
80/******/ return getter;
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +053081 /******/
82};
kumaran.m3b4814a2020-05-01 19:48:54 +053083/******/
84/******/ // Object.prototype.hasOwnProperty.call
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +053085/******/ __webpack_require__.o = function (object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
kumaran.m3b4814a2020-05-01 19:48:54 +053086/******/
87/******/ // __webpack_public_path__
88/******/ __webpack_require__.p = "";
89/******/
90/******/ // Load entry module and return exports
91/******/ return __webpack_require__(__webpack_require__.s = 2);
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +053092 /******/
93})
kumaran.m3b4814a2020-05-01 19:48:54 +053094/************************************************************************/
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +053095/******/([
kumaran.m3b4814a2020-05-01 19:48:54 +053096/* 0 */
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +053097/***/ (function (module, exports) {
kumaran.m3b4814a2020-05-01 19:48:54 +053098
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +053099 /*
100 * tar-js
101 * MIT (c) 2011 T. Jameson Little
102 */
kumaran.m3b4814a2020-05-01 19:48:54 +0530103
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530104 (function () {
105 "use strict";
kumaran.m3b4814a2020-05-01 19:48:54 +0530106
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530107 var lookup = [
108 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
109 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
110 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
111 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
112 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
113 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
114 'w', 'x', 'y', 'z', '0', '1', '2', '3',
115 '4', '5', '6', '7', '8', '9', '+', '/'
116 ];
117 function clean(length) {
118 var i, buffer = new Uint8Array(length);
119 for (i = 0; i < length; i += 1) {
120 buffer[i] = 0;
121 }
122 return buffer;
123 }
kumaran.m3b4814a2020-05-01 19:48:54 +0530124
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530125 function extend(orig, length, addLength, multipleOf) {
126 var newSize = length + addLength,
127 buffer = clean((parseInt(newSize / multipleOf) + 1) * multipleOf);
kumaran.m3b4814a2020-05-01 19:48:54 +0530128
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530129 buffer.set(orig);
kumaran.m3b4814a2020-05-01 19:48:54 +0530130
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530131 return buffer;
132 }
kumaran.m3b4814a2020-05-01 19:48:54 +0530133
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530134 function pad(num, bytes, base) {
135 num = num.toString(base || 8);
136 return "000000000000".substr(num.length + 12 - bytes) + num;
137 }
kumaran.m3b4814a2020-05-01 19:48:54 +0530138
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530139 function stringToUint8(input, out, offset) {
140 var i, length;
kumaran.m3b4814a2020-05-01 19:48:54 +0530141
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530142 out = out || clean(input.length);
kumaran.m3b4814a2020-05-01 19:48:54 +0530143
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530144 offset = offset || 0;
145 for (i = 0, length = input.length; i < length; i += 1) {
146 out[offset] = input.charCodeAt(i);
147 offset += 1;
148 }
kumaran.m3b4814a2020-05-01 19:48:54 +0530149
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530150 return out;
151 }
kumaran.m3b4814a2020-05-01 19:48:54 +0530152
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530153 function uint8ToBase64(uint8) {
154 var i,
155 extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
156 output = "",
157 temp, length;
kumaran.m3b4814a2020-05-01 19:48:54 +0530158
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530159 function tripletToBase64(num) {
160 return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F];
161 };
kumaran.m3b4814a2020-05-01 19:48:54 +0530162
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530163 // go through the array every three bytes, we'll deal with trailing stuff later
164 for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
165 temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]);
166 output += tripletToBase64(temp);
167 }
kumaran.m3b4814a2020-05-01 19:48:54 +0530168
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530169 // this prevents an ERR_INVALID_URL in Chrome (Firefox okay)
170 switch (output.length % 4) {
171 case 1:
172 output += '=';
173 break;
174 case 2:
175 output += '==';
176 break;
177 default:
178 break;
179 }
kumaran.m3b4814a2020-05-01 19:48:54 +0530180
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530181 return output;
182 }
183
184 module.exports.clean = clean;
185 module.exports.pad = pad;
186 module.exports.extend = extend;
187 module.exports.stringToUint8 = stringToUint8;
188 module.exports.uint8ToBase64 = uint8ToBase64;
189 }());
kumaran.m3b4814a2020-05-01 19:48:54 +0530190
191
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530192 /***/
193}),
kumaran.m3b4814a2020-05-01 19:48:54 +0530194/* 1 */
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530195/***/ (function (module, exports, __webpack_require__) {
kumaran.m3b4814a2020-05-01 19:48:54 +0530196
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530197 /*
198 * tar-js
199 * MIT (c) 2011 T. Jameson Little
200 */
kumaran.m3b4814a2020-05-01 19:48:54 +0530201
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530202 (function () {
203 "use strict";
kumaran.m3b4814a2020-05-01 19:48:54 +0530204
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530205 /*
206 struct posix_header { // byte offset
207 char name[100]; // 0
208 char mode[8]; // 100
209 char uid[8]; // 108
210 char gid[8]; // 116
211 char size[12]; // 124
212 char mtime[12]; // 136
213 char chksum[8]; // 148
214 char typeflag; // 156
215 char linkname[100]; // 157
216 char magic[6]; // 257
217 char version[2]; // 263
218 char uname[32]; // 265
219 char gname[32]; // 297
220 char devmajor[8]; // 329
221 char devminor[8]; // 337
222 char prefix[155]; // 345
223 // 500
224 };
225 */
kumaran.m3b4814a2020-05-01 19:48:54 +0530226
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530227 var utils = __webpack_require__(0),
228 headerFormat;
kumaran.m3b4814a2020-05-01 19:48:54 +0530229
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530230 headerFormat = [
231 {
232 'field': 'fileName',
233 'length': 100
234 },
235 {
236 'field': 'fileMode',
237 'length': 8
238 },
239 {
240 'field': 'uid',
241 'length': 8
242 },
243 {
244 'field': 'gid',
245 'length': 8
246 },
247 {
248 'field': 'fileSize',
249 'length': 12
250 },
251 {
252 'field': 'mtime',
253 'length': 12
254 },
255 {
256 'field': 'checksum',
257 'length': 8
258 },
259 {
260 'field': 'type',
261 'length': 1
262 },
263 {
264 'field': 'linkName',
265 'length': 100
266 },
267 {
268 'field': 'ustar',
269 'length': 8
270 },
271 {
272 'field': 'owner',
273 'length': 32
274 },
275 {
276 'field': 'group',
277 'length': 32
278 },
279 {
280 'field': 'majorNumber',
281 'length': 8
282 },
283 {
284 'field': 'minorNumber',
285 'length': 8
286 },
287 {
288 'field': 'filenamePrefix',
289 'length': 155
290 },
291 {
292 'field': 'padding',
293 'length': 12
294 }
295 ];
kumaran.m3b4814a2020-05-01 19:48:54 +0530296
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530297 function formatHeader(data, cb) {
298 var buffer = utils.clean(512),
299 offset = 0;
300
301 headerFormat.forEach(function (value) {
302 var str = data[value.field] || "",
303 i, length;
304
305 for (i = 0, length = str.length; i < length; i += 1) {
306 buffer[offset] = str.charCodeAt(i);
307 offset += 1;
308 }
309
310 offset += value.length - i; // space it out with nulls
311 });
312
313 if (typeof cb === 'function') {
314 return cb(buffer, offset);
315 }
316 return buffer;
kumaran.m3b4814a2020-05-01 19:48:54 +0530317 }
318
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530319 module.exports.structure = headerFormat;
320 module.exports.format = formatHeader;
321 }());
kumaran.m3b4814a2020-05-01 19:48:54 +0530322
323
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530324 /***/
325}),
kumaran.m3b4814a2020-05-01 19:48:54 +0530326/* 2 */
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530327/***/ (function (module, exports, __webpack_require__) {
kumaran.m3b4814a2020-05-01 19:48:54 +0530328
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530329 /*
330 * tar-js
331 * MIT (c) 2011 T. Jameson Little
332 */
kumaran.m3b4814a2020-05-01 19:48:54 +0530333
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530334 (function () {
335 "use strict";
kumaran.m3b4814a2020-05-01 19:48:54 +0530336
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530337 var header = __webpack_require__(1),
338 utils = __webpack_require__(0),
339 recordSize = 512,
340 blockSize;
kumaran.m3b4814a2020-05-01 19:48:54 +0530341
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530342 function Tar(recordsPerBlock) {
343 this.written = 0;
344 blockSize = (recordsPerBlock || 20) * recordSize;
345 this.out = utils.clean(blockSize);
kumaran.m3b4814a2020-05-01 19:48:54 +0530346 }
kumaran.m3b4814a2020-05-01 19:48:54 +0530347
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530348 Tar.prototype.append = function (filepath, input, opts, callback) {
349 var data,
350 checksum,
351 mode,
352 mtime,
353 uid,
354 gid,
355 headerArr;
kumaran.m3b4814a2020-05-01 19:48:54 +0530356
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530357 if (typeof input === 'string') {
358 input = utils.stringToUint8(input);
359 } else if (input.constructor !== Uint8Array.prototype.constructor) {
360 throw 'Invalid input type. You gave me: ' + input.constructor.toString().match(/function\s*([$A-Za-z_][0-9A-Za-z_]*)\s*\(/)[1];
361 }
kumaran.m3b4814a2020-05-01 19:48:54 +0530362
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530363 if (typeof opts === 'function') {
364 callback = opts;
365 opts = {};
366 }
kumaran.m3b4814a2020-05-01 19:48:54 +0530367
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530368 opts = opts || {};
kumaran.m3b4814a2020-05-01 19:48:54 +0530369
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530370 mode = opts.mode || parseInt('777', 8) & 0xfff;
371 mtime = opts.mtime || Math.floor(+new Date() / 1000);
372 uid = opts.uid || 0;
373 gid = opts.gid || 0;
kumaran.m3b4814a2020-05-01 19:48:54 +0530374
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530375 data = {
376 fileName: filepath,
377 fileMode: utils.pad(mode, 7),
378 uid: utils.pad(uid, 7),
379 gid: utils.pad(gid, 7),
380 fileSize: utils.pad(input.length, 11),
381 mtime: utils.pad(mtime, 11),
382 checksum: ' ',
383 type: opts.type || '0',
384 ustar: 'ustar ',
385 owner: opts.owner || '',
386 group: opts.group || '',
387 linkName: opts.linkname || ''
388 };
kumaran.m3b4814a2020-05-01 19:48:54 +0530389
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530390 // calculate the checksum
391 checksum = 0;
392 Object.keys(data).forEach(function (key) {
393 var i, value = data[key], length;
kumaran.m3b4814a2020-05-01 19:48:54 +0530394
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530395 for (i = 0, length = value.length; i < length; i += 1) {
396 checksum += value.charCodeAt(i);
397 }
398 });
kumaran.m3b4814a2020-05-01 19:48:54 +0530399
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530400 data.checksum = utils.pad(checksum, 6) + "\u0000 ";
kumaran.m3b4814a2020-05-01 19:48:54 +0530401
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530402 headerArr = header.format(data);
kumaran.m3b4814a2020-05-01 19:48:54 +0530403
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530404 var i, offset, length;
kumaran.m3b4814a2020-05-01 19:48:54 +0530405
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530406 this.out.set(headerArr, this.written);
407
408 this.written += headerArr.length;
409
410 // If there is not enough space in this.out, we need to expand it to
411 // fit the new input.
412 if (this.written + input.length > this.out.length) {
413 this.out = utils.extend(this.out, this.written, input.length, blockSize);
414 }
415
416 this.out.set(input, this.written);
417
418 // to the nearest multiple of recordSize
419 this.written += input.length + (recordSize - (input.length % recordSize || recordSize));
420
421 // make sure there's at least 2 empty records worth of extra space
422 if (this.out.length - this.written < recordSize * 2) {
423 this.out = utils.extend(this.out, this.written, recordSize * 2, blockSize);
424 }
425
426 if (typeof callback === 'function') {
427 callback(this.out);
428 }
429
430 return this.out;
431 };
432
433 Tar.prototype.clear = function () {
434 this.written = 0;
435 this.out = utils.clean(blockSize);
436 };
437
438 module.exports = Tar;
439 }());
kumaran.m3b4814a2020-05-01 19:48:54 +0530440
441
Barath Kumar Rdb1aeb02020-10-13 18:14:16 +0530442 /***/
443})
444/******/]);