-
Notifications
You must be signed in to change notification settings - Fork 6
/
mkgzip.js
40 lines (33 loc) · 887 Bytes
/
mkgzip.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var util = require( 'util' );
var fs = require( 'graceful-fs' );
var mysql = require( 'mysql' );
var express = require( 'express' );
var app = express();
app.enable( "jsonp callback" );
var http = require( 'http' );
var url = require( 'url' );
var server = http.createServer( app );
var zlib = require( 'zlib' );
//var dir='./games/';
var dir='./games/';
fs.readdir( dir, function _fs_readdir( err, files ) {
if( err ) throw err;
var inp, out;
var c = 0;
var max = files.length;
setImmediate( function next() {
console.log( files[c] );
var gzip = zlib.createGzip();
console.log( c + " " + dir + files[c] );
inp = fs.createReadStream( './games/' + files[c] );
out = fs.createWriteStream( './gzgames/' + files[c] + '.gz' );
inp.pipe( gzip ).pipe( out );
c++;
if( c >= max ) {
console.log( "done!" );
}
else {
setImmediate( next );
}
} );
} );