Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * This file is part of Apparat.
- *
- * Apparat is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Apparat is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Apparat. If not, see <http://www.gnu.org/licenses/>.
- *
- * Copyright (C) 2009 Joa Ebert
- * http://www.joa-ebert.com/
- *
- * User: Patrick Le Clec'h
- */
- // usage : ABCMerger("input file", "output file")
- import apparat.log.{Log, SimpleLog}
- import apparat.log.output.ConsoleOutput
- object ABCMerger extends SimpleLog {
- def apply(input: String, output: String) {
- import apparat.abc.Abc
- import apparat.utils.TagContainer
- import apparat.swf.{SwfTags, DoABC}
- import apparat.abc.analysis.AbcConstantPoolBuilder
- Log.addOutput(new ConsoleOutput())
- val cont = TagContainer fromFile input
- var buffer: Option[Abc] = None
- log.info("Merging abc from : " + input)
- for(tag <- cont.tags filter (tag => tag.kind == SwfTags.DoABC || tag.kind == SwfTags.DoABC1)) {
- tag match {
- case doABC: DoABC => {
- val abc = Abc fromDoABC doABC
- abc.loadBytecode()
- buffer = buffer match {
- case Some(b) => Some(b + abc)
- case None => Some(abc)
- }
- }
- }
- }
- buffer match {
- case Some(b) => {
- val doABC = new DoABC()
- doABC.flags = 1
- doABC.name = "apparat.googlecode.com"
- b.bytecodeAvailable = true
- log.info("Rebuilding cpool...")
- b.cpool = AbcConstantPoolBuilder using b
- b.saveBytecode()
- b write doABC
- log.info("Saving merged abc into " + output)
- Abc.fromDoABC(doABC).write(output)
- }
- case _ => log.info("No abc data found into : " + input)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement