/*
 * This file is part of Mapyrus, software for plotting maps.
 * Copyright (C) 2003 Simon Chenery.
 *
 * Mapyrus is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Mapyrus is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Mapyrus; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

/*
 * @(#) $Id$
 */
package au.id.chenery.mapyrus;

/**
 * A temporary file that is automatically deleted once it expires.
 */
public class TransientFile
{
	String mFilename;
	long mExpiryTimestamp;
	
	/**
	 * Create new transient file.
	 * @param filename name of temporary file.
	 * @param expiry timestamp in milliseconds since 1970 at which the file expires,
	 */
	public TransientFile(String filename, long expiry)
	{
		mFilename = filename;
		mExpiryTimestamp = expiry;	
	}

	/**
	 * Returns name of temporary file.
	 * @return filename.
	 */
	public String getFilename()
	{
		return(mFilename);
	}

	/**
	 * Return expiry timestamp of this temporary file.
	 * @return expiry timestamp measured in milliseconds since 1970.
	 */
	public long getExpiry()
	{
		return(mExpiryTimestamp);
	}
	
	public String toString()
	{
		return(mFilename + " expiring at " + mExpiryTimestamp);
	}
}

@@ -850,16 +850,38 @@
 pyrus;%0A%0A
+import java.io.File;%0A%0A
 /**%0A * A
@@ -941,16 +941,47 @@
  expires
+,%0A * or when the JVM terminates
 .%0A */%0Apu
@@ -1327,16 +1327,68 @@
 expiry;%09
+%0A%0A%09%09File f = new File(filename);%0A%09%09f.deleteOnExit();
 %0A%09%7D%0A%0A%09/*

Delete transient files on exit too so there is less junk laying around.