Use FileUtil.resuffix().
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2763 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -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;
|
package com.threerings.resource;
|
||||||
|
|
||||||
@@ -23,6 +23,7 @@ import com.sun.javaws.cache.Patcher;
|
|||||||
import com.sun.javaws.jardiff.JarDiffPatcher;
|
import com.sun.javaws.jardiff.JarDiffPatcher;
|
||||||
|
|
||||||
import com.samskivert.io.StreamUtil;
|
import com.samskivert.io.StreamUtil;
|
||||||
|
import com.samskivert.util.FileUtil;
|
||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
|
|
||||||
import com.threerings.resource.DownloadManager.DownloadDescriptor;
|
import com.threerings.resource.DownloadManager.DownloadDescriptor;
|
||||||
@@ -39,7 +40,7 @@ public class JNLPDownloader extends Downloader
|
|||||||
super.init(ddesc);
|
super.init(ddesc);
|
||||||
|
|
||||||
// determine which version we already have, if any
|
// 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 {
|
try {
|
||||||
BufferedReader vin = new BufferedReader(new FileReader(_vfile));
|
BufferedReader vin = new BufferedReader(new FileReader(_vfile));
|
||||||
_cvers = vin.readLine();
|
_cvers = vin.readLine();
|
||||||
@@ -101,7 +102,8 @@ public class JNLPDownloader extends Downloader
|
|||||||
// determine whether or not this is a patch
|
// determine whether or not this is a patch
|
||||||
if (ucon.getContentType().equals(JARDIFF_TYPE)) {
|
if (ucon.getContentType().equals(JARDIFF_TYPE)) {
|
||||||
Log.info("Downloading patch [url=" + rsrcURL + "].");
|
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);
|
downloadContent(dmgr, obs, pinfo, buffer, ucon, _patchFile);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -117,7 +119,8 @@ public class JNLPDownloader extends Downloader
|
|||||||
{
|
{
|
||||||
if (_patchFile != null) {
|
if (_patchFile != null) {
|
||||||
// move the old jar out of the way
|
// 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)) {
|
if (!_desc.destFile.renameTo(oldDest)) {
|
||||||
Log.warning("Unable to move " + _desc.destFile + " to " +
|
Log.warning("Unable to move " + _desc.destFile + " to " +
|
||||||
oldDest + ". Cleaning up and failing.");
|
oldDest + ". Cleaning up and failing.");
|
||||||
@@ -165,20 +168,6 @@ public class JNLPDownloader extends Downloader
|
|||||||
// Log.info("Updated version to " + _desc.version + ".");
|
// Log.info("Updated version to " + _desc.version + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Replaces <code>.jar</code> with the supplied new extention if the
|
|
||||||
* supplied file path ends in <code>.jar</code>. 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
|
* Constructs the resource URL using the source URL supplied in the
|
||||||
* download descriptor and any version information that is
|
* download descriptor and any version information that is
|
||||||
|
|||||||
Reference in New Issue
Block a user