STGBuilder GAME.DAT Dumper
Revisão | 92b1ade1cd0ec1f741a5a98b0fbfb51294107963 (tree) |
---|---|
Hora | 2021-05-05 18:11:35 |
Autor | Remilia Scarlet <remilia@post...> |
Commiter | Remilia Scarlet |
Add --quiet option, and convert yen signs to slashes to account for
directories.
@@ -1,2 +1,4 @@ | ||
1 | 1 | syntax: glob |
2 | -*.[dD][aA][tT] | |
\ No newline at end of file | ||
2 | +*.[dD][aA][tT] | |
3 | +lib/* | |
4 | +bin/* |
@@ -74,14 +74,21 @@ | ||
74 | 74 | end |
75 | 75 | end |
76 | 76 | |
77 | - def dump(src : IO, outdir : String) | |
78 | - Dir.mkdir_p(outdir) unless Dir.exists?(outdir) | |
77 | + def dump(src : IO, outdir : String, quiet : Bool) | |
79 | 78 | total = 0 |
80 | 79 | |
81 | 80 | entries.each do |ent| |
82 | - filename = Path[outdir, ent.name] | |
81 | + withSlashes = ent.name.gsub('¥', '/') # Yen signs are used for directory separators | |
82 | + filename = Path[outdir, withSlashes] | |
83 | 83 | |
84 | - STDOUT << "#{ent.name}... " | |
84 | + puts filename | |
85 | + | |
86 | + unless Dir.exists?(filename.dirname) | |
87 | + puts "Creating #{filename.dirname}/" | |
88 | + Dir.mkdir_p(filename.dirname) | |
89 | + end | |
90 | + | |
91 | + STDOUT << "#{ent.name}... " unless quiet | |
85 | 92 | begin |
86 | 93 | File.open(filename, "w") do |file| |
87 | 94 | src.pos = ent.offset |
@@ -90,7 +97,7 @@ | ||
90 | 97 | |
91 | 98 | size = File.size(filename) |
92 | 99 | total += size |
93 | - STDOUT << "done, #{size.humanize_bytes(format: Int::BinaryPrefixFormat::JEDEC)}\n" | |
100 | + STDOUT << "done, #{size.humanize_bytes(format: Int::BinaryPrefixFormat::JEDEC)}\n" unless quiet | |
94 | 101 | rescue err : Exception |
95 | 102 | STDOUT << "error! #{err.message || "unknown error"}\n" |
96 | 103 | end |
@@ -107,6 +114,7 @@ | ||
107 | 114 | args.addString("file", 'f', help: "The filename to read") |
108 | 115 | args.addString("outdir", 'o', help: "The directory to save files into") |
109 | 116 | args.addFlag("list", 'l', help: "Don't dump anything, just list files") |
117 | + args.addFlag("quiet", 'q', help: "Print only minimal information") | |
110 | 118 | |
111 | 119 | begin |
112 | 120 | args.parse(ARGV) |
@@ -129,7 +137,7 @@ | ||
129 | 137 | abort("No output directory specified") unless args["outdir"].called |
130 | 138 | |
131 | 139 | File.open(args["file"].str) do |file| |
132 | - total = dat.dump(file, args["outdir"].str) | |
140 | + total = dat.dump(file, args["outdir"].str, args["quiet"].called) | |
133 | 141 | puts "Files dumped: #{dat.entries.size}" |
134 | 142 | puts "Total size: #{total.humanize_bytes(format: Int::BinaryPrefixFormat::JEDEC)}" |
135 | 143 | end |