Bug 1253 Updating the VNFD via ngUI breaks charms execution
[osm/NG-UI.git] / src / assets / js / tar.js
1 /*
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 */
18 var Tar =
19 /******/ (function (modules) { // webpackBootstrap
20 /******/ // The module cache
21 /******/ var installedModules = {};
22 /******/
23 /******/ // The require function
24 /******/ function __webpack_require__(moduleId) {
25 /******/
26 /******/ // Check if module is in cache
27 /******/ if (installedModules[moduleId]) {
28 /******/ return installedModules[moduleId].exports;
29 /******/
30 }
31 /******/ // Create a new module (and put it into the cache)
32 /******/ var module = installedModules[moduleId] = {
33 /******/ i: moduleId,
34 /******/ l: false,
35 /******/ exports: {}
36 /******/
37 };
38 /******/
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;
47 /******/
48 }
49 /******/
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
58 /******/ __webpack_require__.i = function (value) { return value; };
59 /******/
60 /******/ // define getter function for harmony exports
61 /******/ __webpack_require__.d = function (exports, name, getter) {
62 /******/ if (!__webpack_require__.o(exports, name)) {
63 /******/ Object.defineProperty(exports, name, {
64 /******/ configurable: false,
65 /******/ enumerable: true,
66 /******/ get: getter
67 /******/
68 });
69 /******/
70 }
71 /******/
72 };
73 /******/
74 /******/ // getDefaultExport function for compatibility with non-harmony modules
75 /******/ __webpack_require__.n = function (module) {
76 /******/ 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;
81 /******/
82 };
83 /******/
84 /******/ // Object.prototype.hasOwnProperty.call
85 /******/ __webpack_require__.o = function (object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
86 /******/
87 /******/ // __webpack_public_path__
88 /******/ __webpack_require__.p = "";
89 /******/
90 /******/ // Load entry module and return exports
91 /******/ return __webpack_require__(__webpack_require__.s = 2);
92 /******/
93 })
94 /************************************************************************/
95 /******/([
96 /* 0 */
97 /***/ (function (module, exports) {
98
99 /*
100 * tar-js
101 * MIT (c) 2011 T. Jameson Little
102 */
103
104 (function () {
105 "use strict";
106
107 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 }
124
125 function extend(orig, length, addLength, multipleOf) {
126 var newSize = length + addLength,
127 buffer = clean((parseInt(newSize / multipleOf) + 1) * multipleOf);
128
129 buffer.set(orig);
130
131 return buffer;
132 }
133
134 function pad(num, bytes, base) {
135 num = num.toString(base || 8);
136 return "000000000000".substr(num.length + 12 - bytes) + num;
137 }
138
139 function stringToUint8(input, out, offset) {
140 var i, length;
141
142 out = out || clean(input.length);
143
144 offset = offset || 0;
145 for (i = 0, length = input.length; i < length; i += 1) {
146 out[offset] = input.charCodeAt(i);
147 offset += 1;
148 }
149
150 return out;
151 }
152
153 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;
158
159 function tripletToBase64(num) {
160 return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F];
161 };
162
163 // 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 }
168
169 // 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 }
180
181 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 }());
190
191
192 /***/
193 }),
194 /* 1 */
195 /***/ (function (module, exports, __webpack_require__) {
196
197 /*
198 * tar-js
199 * MIT (c) 2011 T. Jameson Little
200 */
201
202 (function () {
203 "use strict";
204
205 /*
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 */
226
227 var utils = __webpack_require__(0),
228 headerFormat;
229
230 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 ];
296
297 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;
317 }
318
319 module.exports.structure = headerFormat;
320 module.exports.format = formatHeader;
321 }());
322
323
324 /***/
325 }),
326 /* 2 */
327 /***/ (function (module, exports, __webpack_require__) {
328
329 /*
330 * tar-js
331 * MIT (c) 2011 T. Jameson Little
332 */
333
334 (function () {
335 "use strict";
336
337 var header = __webpack_require__(1),
338 utils = __webpack_require__(0),
339 recordSize = 512,
340 blockSize;
341
342 function Tar(recordsPerBlock) {
343 this.written = 0;
344 blockSize = (recordsPerBlock || 20) * recordSize;
345 this.out = utils.clean(blockSize);
346 }
347
348 Tar.prototype.append = function (filepath, input, opts, callback) {
349 var data,
350 checksum,
351 mode,
352 mtime,
353 uid,
354 gid,
355 headerArr;
356
357 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 }
362
363 if (typeof opts === 'function') {
364 callback = opts;
365 opts = {};
366 }
367
368 opts = opts || {};
369
370 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;
374
375 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 };
389
390 // calculate the checksum
391 checksum = 0;
392 Object.keys(data).forEach(function (key) {
393 var i, value = data[key], length;
394
395 for (i = 0, length = value.length; i < length; i += 1) {
396 checksum += value.charCodeAt(i);
397 }
398 });
399
400 data.checksum = utils.pad(checksum, 6) + "\u0000 ";
401
402 headerArr = header.format(data);
403
404 var i, offset, length;
405
406 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 }());
440
441
442 /***/
443 })
444 /******/]);