-
Notifications
You must be signed in to change notification settings - Fork 24
/
Postbuild.hx
49 lines (43 loc) · 1.35 KB
/
Postbuild.hx
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
39
40
41
42
43
44
45
46
47
48
49
package art;
using DateTools;
class Postbuild
{
static function main()
{
/* trace('creating NG zip');
var binFolder:String = 'export/release/html5/bin/';
var date = Date.now();
var outputName:String = 'NG-' + date.format("%Y%m%d--%H%M") + '.zip';
var out = sys.io.File.write(outputName);
var zip = new haxe.zip.Writer(out);
zip.write(getEntries(binFolder));
trace('Finished creating ZIP');
*/
}
static function getEntries(dir:String, entries:List<haxe.zip.Entry> = null, inDir:Null<String> = null)
{
if (entries == null) entries = new List<haxe.zip.Entry>();
if (inDir == null) inDir = dir;
for (file in sys.FileSystem.readDirectory(dir))
{
var path = haxe.io.Path.join([dir, file]);
if (sys.FileSystem.isDirectory(path)) getEntries(path, entries, inDir);
else
{
var bytes:haxe.io.Bytes = haxe.io.Bytes.ofData(sys.io.File.getBytes(path).getData());
var entry:haxe.zip.Entry =
{
fileName: StringTools.replace(path, inDir, ""),
fileSize: bytes.length,
fileTime: Date.now(),
compressed: false,
dataSize: sys.FileSystem.stat(path).size,
data: bytes,
crc32: haxe.crypto.Crc32.make(bytes)
};
entries.push(entry);
}
}
return entries;
}
}