Created
June 28, 2017 07:07
-
-
Save anonymous/1692ab3a388b421b8f99f019aec28f45 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
const fs = require("fs"); | |
const path = require("path"); | |
const FS_OPTS = {encoding: "utf8"}; | |
// const RE_RAP = /;([^;]+\.rap);([0-9a-f]+);/ig; | |
const RE_RAP = /;([0-9a-z_\-]+\.rap);([0-9a-f]{32,32});/ig; | |
const INPUT = "db"; | |
const OUT_DIR = "exdata"; | |
if(!fs.existsSync(OUT_DIR)){ | |
fs.mkdirSync(OUT_DIR); | |
} | |
const input = fs.readFileSync(INPUT, FS_OPTS); | |
let m, count = 0; | |
while((m = RE_RAP.exec(input)) != null){ | |
++ count; | |
let out_name = path.join(OUT_DIR, m[1]); | |
if(!fs.existsSync(out_name)){ | |
console.log("new: " + out_name + " " + m[2]); | |
fs.writeFileSync(out_name, Buffer.from(m[2], "hex")); | |
} | |
} | |
console.log(count); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment