From 88cc8303fa71269fccc33c09d32fb6a7f0f4dc24 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Tue, 14 Jan 2003 00:58:59 +0000 Subject: [PATCH] Update cached resource files when appropriate. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2134 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../com/threerings/resource/ResourceBundle.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/java/com/threerings/resource/ResourceBundle.java b/src/java/com/threerings/resource/ResourceBundle.java index ac77b9589..89e012d01 100644 --- a/src/java/com/threerings/resource/ResourceBundle.java +++ b/src/java/com/threerings/resource/ResourceBundle.java @@ -1,5 +1,5 @@ // -// $Id: ResourceBundle.java,v 1.5 2003/01/13 22:50:36 mdb Exp $ +// $Id: ResourceBundle.java,v 1.6 2003/01/14 00:58:59 mdb Exp $ package com.threerings.resource; @@ -32,6 +32,7 @@ public class ResourceBundle public ResourceBundle (File source) { _source = source; + _sourceLastMod = source.lastModified(); } /** @@ -83,7 +84,9 @@ public class ResourceBundle // compute the path to our temporary file String tpath = StringUtil.md5hex(_source.getPath() + "%" + path); File tfile = new File(_tmpdir, tpath); - if (tfile.exists()) { + if (tfile.exists() && (tfile.lastModified() > _sourceLastMod)) { + System.out.println("Using cached " + _source.getPath() + + ":" + path); return tfile; } @@ -93,9 +96,7 @@ public class ResourceBundle return null; } - // clean up our unpacked files when the JVM exits -// tfile.deleteOnExit(); - + System.out.println("Unpacking " + path); // copy the resource into the temporary file BufferedOutputStream fout = new BufferedOutputStream(new FileOutputStream(tfile)); @@ -161,6 +162,9 @@ public class ResourceBundle /** The file from which we construct our jar file. */ protected File _source; + /** The last modified time of our source jar file. */ + protected long _sourceLastMod; + /** The directory into which our contents are unpacked, if we are * unpacked. */ protected File _unpackDir;