01: /* ===========================================================================
02: * $RCSfile: RGdefaultImpl.java,v $
03: * ===========================================================================
04: *
05: * RetroGuard -- an obfuscation package for Java classfiles.
06: *
07: * Copyright (c) 1998-2006 Mark Welsh (markw@retrologic.com)
08: *
09: * This program can be redistributed and/or modified under the terms of the
10: * Version 2 of the GNU General Public License as published by the Free
11: * Software Foundation.
12: *
13: * This program is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: * GNU General Public License for more details.
17: *
18: */
19:
20: package COM.rl.obf;
21:
22: import java.io.*;
23: import java.util.*;
24: import COM.rl.obf.patch.*;
25:
26: /**
27: * Main class for utility to output the internal default script file.
28: *
29: * @author Mark Welsh
30: */
31: public class RGdefaultImpl {
32: // Class Methods ---------------------------------------------------------
33: /**
34: * Main entry point.
35: *
36: * @param rgsFilename output file name
37: */
38: public static void output(String rgsFilename) throws Exception {
39: File rgsFile = rgsFilename == null ? null : new File(
40: rgsFilename);
41:
42: // Output list file must be writable if it exists
43: if (rgsFile != null && rgsFile.exists() && !rgsFile.canWrite()) {
44: throw new IllegalArgumentException(
45: "Output file cannot be written to.");
46: }
47:
48: // Call the main entry point
49: RGdefaultImpl.output(rgsFile);
50: }
51:
52: /**
53: * Main entry point for the converter.
54: *
55: * @param rgsFile output file
56: */
57: public static void output(File rgsFile) throws Exception {
58: // Write the output file
59: PrintStream out = null;
60: try {
61: out = rgsFile == null ? System.out : new PrintStream(
62: new BufferedOutputStream(new FileOutputStream(
63: rgsFile)));
64: out
65: .println("# The RetroGuard internal default script is listed below.");
66: out
67: .println("# You can comment out or add lines to change how the obfuscator works.");
68: out
69: .println("# Please refer to http://retrologic.com/retroguard-docs.html for more details.");
70: out.print(RgsEnum.getDefaultRgs());
71: out.flush();
72: } finally {
73: if (out != null) {
74: out.close();
75: }
76: }
77: }
78: }
|