2011-06-04 21:58:10 +02:00
|
|
|
<html>
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<title>Browser Tar</title>
|
|
|
|
|
|
|
|
<script src='../node_modules/require-kiss/require-kiss.js'></script>
|
|
|
|
<script src='../lib/utils.js'></script>
|
|
|
|
<script src='../lib/header.js'></script>
|
|
|
|
<script src='../lib/tar.js'></script>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
(function () {
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var Tar = require('tar'),
|
|
|
|
utils = require('utils'),
|
|
|
|
tape = new Tar(),
|
|
|
|
out,
|
|
|
|
url,
|
|
|
|
base64;
|
|
|
|
|
2011-08-01 04:09:56 +02:00
|
|
|
function uint8ToString(buf) {
|
|
|
|
var i, length, out = '';
|
|
|
|
for (i = 0, length = buf.length; i < length; i += 1) {
|
|
|
|
out += String.fromCharCode(buf[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2011-06-04 21:58:10 +02:00
|
|
|
out = tape.append('output.txt', 'This is test1!');
|
|
|
|
out = tape.append('dir/out.txt', 'This is test2! I changed up the directory');
|
|
|
|
out = tape.append('arr.txt', utils.stringToUint8('This is a Uint8Array!'));
|
|
|
|
|
2011-08-01 04:09:56 +02:00
|
|
|
base64 = btoa(uint8ToString(out));
|
2011-06-04 21:58:10 +02:00
|
|
|
|
|
|
|
url = "data:application/tar;base64," + base64;
|
|
|
|
window.open(url);
|
|
|
|
}());
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
</body>
|
|
|
|
</html>
|