|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectomero.util.TempFileManager
public class TempFileManager
Creates temporary files and folders and makes a best effort to remove them on
exit (or sooner). Typically only a single instance of this class will exist
(static manager
constant)
Constructor Summary | |
---|---|
TempFileManager()
Default constructor, passes "omero" to TempFileManager(String) |
|
TempFileManager(String prefix)
Initializes a TempFileManager instance with a userDir
containing the given prefix value. |
Method Summary | |
---|---|
protected boolean |
access(File dir)
Returns true if the current user can write to the give directory. |
protected void |
cleanTempDir()
Deletes dir |
protected void |
cleanup()
Releases lock and deletes dir . |
protected void |
cleanUserDir()
Attempts to delete all directories under self.userdir other than the one owned by this process. |
static File |
create_path()
Calls createPath(String, String, boolean) on manager
with defaults of "omero", ".tmp", and false. |
static File |
create_path(String prefix)
Calls createPath(String, String, boolean) on manager
with defaults of ".tmp", and false. |
static File |
create_path(String prefix,
String suffix)
Calls createPath(String, String, boolean) on manager
with ".tmp", and false arguments. |
static File |
create_path(String prefix,
String suffix,
boolean folder)
Calls createPath(String, String, boolean) on manager . |
protected boolean |
create(File dir)
If the given directory doesn't exist, creates it and returns true. |
File |
createPath(String prefix,
String suffix,
boolean folder)
Uses File.createTempFile(String, String, File) to create
temporary files and folders under dir . |
static File |
createTempFile(String prefix,
String suffix)
Emulates File.createTempFile(String, String) by calling
create_path(String, String) . |
File |
getTempDir()
Returns the directory under which all temporary files and folders will be created. |
static void |
main(String[] _args)
Command-line interface to the global TempFileManager instance (
#manger ). |
protected String |
pid()
Returns some representation of the current process's id |
static void |
remove_path(File file)
Calls removePath(File) on manager . |
void |
removePath(File file)
If the given file is under dir , then it is deleted whether file
or folder. |
protected File |
tmpdir()
Returns a platform-specific user-writable temporary directory. |
protected String |
username()
Returns the current OS-user's name. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TempFileManager()
TempFileManager(String)
public TempFileManager(String prefix)
TempFileManager
instance with a userDir
containing the given prefix value. Also adds a
shutdown hook
to call
cleanup()
on exit.
Method Detail |
---|
protected void cleanup() throws IOException
lock
and deletes dir
. The lock is released
first since on some platforms like Windows the lock file cannot be
deleted even by the owner of the lock.
IOException
protected File tmpdir()
protected String username()
protected String pid()
protected boolean access(File dir)
protected boolean create(File dir)
public File getTempDir()
public File createPath(String prefix, String suffix, boolean folder) throws IOException
File.createTempFile(String, String, File)
to create
temporary files and folders under dir
. For folders, first a
temporary file is created, then deleted, and finally a directory
produced.
IOException
public void removePath(File file) throws IOException
dir
, then it is deleted whether file
or folder. Otherwise a RuntimeException
is thrown.
IOException
protected void cleanTempDir() throws IOException
dir
IOException
protected void cleanUserDir() throws IOException
IOException
public static File createTempFile(String prefix, String suffix) throws IOException
File.createTempFile(String, String)
by calling
create_path(String, String)
.
IOException
public static File create_path() throws IOException
createPath(String, String, boolean)
on manager
with defaults of "omero", ".tmp", and false.
IOException
public static File create_path(String prefix) throws IOException
createPath(String, String, boolean)
on manager
with defaults of ".tmp", and false.
IOException
public static File create_path(String prefix, String suffix) throws IOException
createPath(String, String, boolean)
on manager
with ".tmp", and false arguments.
IOException
public static File create_path(String prefix, String suffix, boolean folder) throws IOException
createPath(String, String, boolean)
on manager
.
IOException
public static void remove_path(File file) throws IOException
removePath(File)
on manager
.
IOException
public static void main(String[] _args) throws IOException
TempFileManager
instance (
#manger
). Valid arguments: "--debug", "clean", "dir", and for
testing, "lock"
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Version: Beta4.2.1-r8614-Beta4.2-b41
Copyright © 2009 The University of Dundee. All Rights Reserved.