Class TemporaryFile
java.lang.Object
velox.api.layer1.common.temporaryfiles.TemporaryFile
public class TemporaryFile
extends java.lang.Object
Manages files and folders inside temporary folder ensuring automatic deletion
when unlocked or during startup. Only attempts to delete unlocked files/folders.
-
Constructor Summary
Constructors Modifier Constructor Description TemporaryFile(java.nio.file.Path pathToFile, boolean isDirectory)
Create a temporary file abstraction.protected
TemporaryFile(velox.api.layer1.common.temporaryfiles.TemporaryFileDirectory temporaryFolder, java.nio.file.Path filePathRelativeToFolder, boolean isDirectory)
-
Method Summary
Modifier and Type Method Description void
create()
Creates lock file and, ifisDirectory
set to true also creates the empty folder.void
dispose()
Unlock the file/folder and remove it (recursively, if it's a folder).void
dispose(boolean removeFile, boolean throwException)
Unlock the file/folder and can remove it (recursively, if it's a folder).java.nio.file.Path
getPath()
Provides full normalized path to managed file
-
Constructor Details
-
TemporaryFile
public TemporaryFile(java.nio.file.Path pathToFile, boolean isDirectory)Create a temporary file abstraction. Doesn't actually perform any filesystem operations yet.- Parameters:
pathToFile
- relative path to the new file/directory within bookmap temporary folderisDirectory
- if true temporary file will be a directory, otherwise it's a plain file
-
TemporaryFile
protected TemporaryFile(velox.api.layer1.common.temporaryfiles.TemporaryFileDirectory temporaryFolder, java.nio.file.Path filePathRelativeToFolder, boolean isDirectory)
-
-
Method Details
-
getPath
public java.nio.file.Path getPath()Provides full normalized path to managed file -
create
public void create()Creates lock file and, ifisDirectory
set to true also creates the empty folder. -
dispose
public void dispose()Unlock the file/folder and remove it (recursively, if it's a folder). Throws and exception is something goes wrong. -
dispose
public void dispose(boolean removeFile, boolean throwException)Unlock the file/folder and can remove it (recursively, if it's a folder). Can throw and exception is something goes wrong.- Parameters:
removeFile
- if true - remove the locked file/folderthrowException
- if true - exception is thrown on failure. Otherwise it's logged but not thrown.
-