Constructor and Description |
---|
TempFileManager()
Default constructor, passes "omero" to
TempFileManager(String) |
TempFileManager(String prefix)
Initializes a
TempFileManager instance with a userDir
containing the given prefix value. |
Modifier and Type | Method and Description |
---|---|
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()
|
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) . |
static void |
gettempdir()
Calls
getTempDir() on manager . |
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.
|
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.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 gettempdir()
getTempDir()
on manager
.public static void main(String[] _args) throws IOException
TempFileManager
instance (
#manger
). Valid arguments: "--debug", "clean", "dir", and for
testing, "lock"IOException
Version: 5.1.2-ice35-b45
Copyright © 2015 The University of Dundee & Open Microscopy Environment. All Rights Reserved.