From 6aa3d95c5e61ca6aa958b8ca43fbee2e71cf0e54 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Mon, 19 Jun 2006 22:33:28 +0000 Subject: [PATCH] Added some hackery to create an installer.txt file which is how we communicate our affiliate status to the Yohoho client (and potentially others in the future). --- .../getdown/launcher/GetdownApplet.java | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/src/java/com/threerings/getdown/launcher/GetdownApplet.java b/src/java/com/threerings/getdown/launcher/GetdownApplet.java index d42c7c0..7cc50d7 100644 --- a/src/java/com/threerings/getdown/launcher/GetdownApplet.java +++ b/src/java/com/threerings/getdown/launcher/GetdownApplet.java @@ -56,6 +56,15 @@ public class GetdownApplet extends JApplet } } + // if an installer.txt file is desired, create that + String inststr = getParameter("installer"); + if (!StringUtil.isBlank(inststr)) { + File infile = new File(appDir, "installer.txt"); + if (!infile.exists()) { + writeToFile(infile, inststr); + } + } + // if our getdown.txt file does not exist, auto-create it File gdfile = new File(appDir, "getdown.txt"); if (!gdfile.exists()) { @@ -66,14 +75,8 @@ public class GetdownApplet extends JApplet // TODO: report return; } - try { - PrintStream out = new PrintStream(new FileOutputStream(gdfile)); - out.println("appbase = " + appbase); - out.close(); - } catch (IOException ioe) { - Log.warning("Failed to create '" + gdfile + "'."); - Log.logStackTrace(ioe); - // TODO: report + if (!writeToFile(gdfile, "appbase = " + appbase)) { + // TODO: report the error return; } } @@ -152,6 +155,23 @@ public class GetdownApplet extends JApplet // TODO } + /** + * Creates the specified file and writes the supplied contents to it. + */ + protected boolean writeToFile (File tofile, String contents) + { + try { + PrintStream out = new PrintStream(new FileOutputStream(tofile)); + out.println(contents); + out.close(); + return true; + } catch (IOException ioe) { + Log.warning("Failed to create '" + tofile + "'."); + Log.logStackTrace(ioe); + return false; + } + } + protected Getdown _getdown; protected Image _bgimage; }