public class TempFileManager
extends java.lang.Object
manager constant)| Constructor and Description |
|---|
TempFileManager()
Default constructor, passes "omero" to
TempFileManager(String) |
TempFileManager(java.lang.String prefix)
Initializes a
TempFileManager instance with a userDir
containing the given prefix value. |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
access(java.io.File dir)
Returns true if the current user can write to the give directory.
|
protected void |
cleanTempDir()
Deletes
dir |
protected void |
cleanup()
|
protected void |
cleanUserDir()
Attempts to delete all directories under self.userdir other than the one
owned by this process.
|
static java.io.File |
create_path()
Calls
createPath(String, String, boolean) on manager
with defaults of "omero", ".tmp", and false. |
static java.io.File |
create_path(java.lang.String prefix)
Calls
createPath(String, String, boolean) on manager
with defaults of ".tmp", and false. |
static java.io.File |
create_path(java.lang.String prefix,
java.lang.String suffix)
Calls
createPath(String, String, boolean) on manager
with ".tmp", and false arguments. |
static java.io.File |
create_path(java.lang.String prefix,
java.lang.String suffix,
boolean folder)
Calls
createPath(String, String, boolean) on manager. |
protected boolean |
create(java.io.File dir)
If the given directory doesn't exist, creates it and returns true.
|
java.io.File |
createPath(java.lang.String prefix,
java.lang.String suffix,
boolean folder)
Uses
File.createTempFile(String, String, File) to create
temporary files and folders under dir. |
static java.io.File |
createTempFile(java.lang.String prefix,
java.lang.String suffix)
Emulates
File.createTempFile(String, String) by calling
create_path(String, String). |
static void |
gettempdir()
Calls
getTempDir() on manager. |
java.io.File |
getTempDir()
Returns the directory under which all temporary files and folders will be
created.
|
static void |
main(java.lang.String[] _args)
Command-line interface to the global
TempFileManager instance (
#manger). |
protected java.lang.String |
pid()
Returns some representation of the current process's id
|
static void |
remove_path(java.io.File file)
Calls
removePath(File) on manager. |
void |
removePath(java.io.File file)
If the given file is under
dir, then it is deleted whether file
or folder. |
protected java.io.File |
tmpdir()
Returns a platform-specific user-writable temporary directory.
|
protected java.lang.String |
username()
Returns the current OS-user's name.
|
public TempFileManager()
TempFileManager(String)public TempFileManager(java.lang.String prefix)
TempFileManager instance with a userDir
containing the given prefix value. Also adds a
shutdown hook to call
cleanup() on exit.protected void cleanup()
throws java.io.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.java.io.IOExceptionprotected java.io.File tmpdir()
protected java.lang.String username()
protected java.lang.String pid()
protected boolean access(java.io.File dir)
protected boolean create(java.io.File dir)
public java.io.File getTempDir()
public java.io.File createPath(java.lang.String prefix,
java.lang.String suffix,
boolean folder)
throws java.io.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.java.io.IOExceptionpublic void removePath(java.io.File file)
throws java.io.IOException
dir, then it is deleted whether file
or folder. Otherwise a RuntimeException is thrown.java.io.IOExceptionprotected void cleanTempDir()
throws java.io.IOException
dirjava.io.IOExceptionprotected void cleanUserDir()
throws java.io.IOException
java.io.IOExceptionpublic static java.io.File createTempFile(java.lang.String prefix,
java.lang.String suffix)
throws java.io.IOException
File.createTempFile(String, String) by calling
create_path(String, String).java.io.IOExceptionpublic static java.io.File create_path()
throws java.io.IOException
createPath(String, String, boolean) on manager
with defaults of "omero", ".tmp", and false.java.io.IOExceptionpublic static java.io.File create_path(java.lang.String prefix)
throws java.io.IOException
createPath(String, String, boolean) on manager
with defaults of ".tmp", and false.java.io.IOExceptionpublic static java.io.File create_path(java.lang.String prefix,
java.lang.String suffix)
throws java.io.IOException
createPath(String, String, boolean) on manager
with ".tmp", and false arguments.java.io.IOExceptionpublic static java.io.File create_path(java.lang.String prefix,
java.lang.String suffix,
boolean folder)
throws java.io.IOException
createPath(String, String, boolean) on manager.java.io.IOExceptionpublic static void remove_path(java.io.File file)
throws java.io.IOException
removePath(File) on manager.java.io.IOExceptionpublic static void gettempdir()
getTempDir() on manager.public static void main(java.lang.String[] _args)
throws java.io.IOException
TempFileManager instance (
#manger). Valid arguments: "--debug", "clean", "dir", and for
testing, "lock"java.io.IOException