From 927881306dc85e45778a88785ccb994e0348ccf9 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Sat, 9 Aug 2003 05:27:07 +0000 Subject: [PATCH] Use FileUtil.resuffix(). git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2763 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../threerings/resource/JNLPDownloader.java | 25 ++++++------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/java/com/threerings/resource/JNLPDownloader.java b/src/java/com/threerings/resource/JNLPDownloader.java index 89a5f36bc..1d42e4498 100644 --- a/src/java/com/threerings/resource/JNLPDownloader.java +++ b/src/java/com/threerings/resource/JNLPDownloader.java @@ -1,5 +1,5 @@ // -// $Id: JNLPDownloader.java,v 1.5 2003/08/08 23:45:39 mdb Exp $ +// $Id: JNLPDownloader.java,v 1.6 2003/08/09 05:27:07 mdb Exp $ package com.threerings.resource; @@ -23,6 +23,7 @@ import com.sun.javaws.cache.Patcher; import com.sun.javaws.jardiff.JarDiffPatcher; import com.samskivert.io.StreamUtil; +import com.samskivert.util.FileUtil; import com.samskivert.util.StringUtil; import com.threerings.resource.DownloadManager.DownloadDescriptor; @@ -39,7 +40,7 @@ public class JNLPDownloader extends Downloader super.init(ddesc); // determine which version we already have, if any - _vfile = new File(mungePath(_desc.destFile, ".vers")); + _vfile = new File(FileUtil.resuffix(_desc.destFile, ".jar", ".vers")); try { BufferedReader vin = new BufferedReader(new FileReader(_vfile)); _cvers = vin.readLine(); @@ -101,7 +102,8 @@ public class JNLPDownloader extends Downloader // determine whether or not this is a patch if (ucon.getContentType().equals(JARDIFF_TYPE)) { Log.info("Downloading patch [url=" + rsrcURL + "]."); - _patchFile = new File(mungePath(_desc.destFile, ".diff")); + _patchFile = new File( + FileUtil.resuffix(_desc.destFile, ".jar", ".diff")); downloadContent(dmgr, obs, pinfo, buffer, ucon, _patchFile); } else { @@ -117,7 +119,8 @@ public class JNLPDownloader extends Downloader { if (_patchFile != null) { // move the old jar out of the way - File oldDest = new File(mungePath(_desc.destFile, ".old")); + File oldDest = new File( + FileUtil.resuffix(_desc.destFile, ".jar", ".old")); if (!_desc.destFile.renameTo(oldDest)) { Log.warning("Unable to move " + _desc.destFile + " to " + oldDest + ". Cleaning up and failing."); @@ -165,20 +168,6 @@ public class JNLPDownloader extends Downloader // Log.info("Updated version to " + _desc.version + "."); } - /** - * Replaces .jar with the supplied new extention if the - * supplied file path ends in .jar. Otherwise the new - * extension is appended to the whole existing file path. - */ - protected String mungePath (File file, String newext) - { - String path = file.getPath(); - if (path.endsWith(".jar")) { - path = path.substring(0, path.length()-4); - } - return path + newext; - } - /** * Constructs the resource URL using the source URL supplied in the * download descriptor and any version information that is