Class TemporaryFile
java.lang.Object
velox.api.layer1.common.temporaryfiles.TemporaryFile
Manages files and folders inside temporary folder ensuring automatic deletion
when unlocked or during startup. Only attempts to delete unlocked files/folders.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionTemporaryFile(Path pathToFile, boolean isDirectory) Create a temporary file abstraction.protectedTemporaryFile(velox.api.layer1.common.temporaryfiles.TemporaryFileDirectory temporaryFolder, Path filePathRelativeToFolder, boolean isDirectory) -
Method Summary
Modifier and TypeMethodDescriptionvoidcreate()Creates lock file and, ifisDirectoryset to true also creates the empty folder.voiddispose()Unlock the file/folder and remove it (recursively, if it's a folder).voiddispose(boolean removeFile, boolean throwException) Unlock the file/folder and can remove it (recursively, if it's a folder).getPath()Provides full normalized path to managed file
-
Constructor Details
-
TemporaryFile
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, Path filePathRelativeToFolder, boolean isDirectory)
-
-
Method Details
-
getPath
Provides full normalized path to managed file -
create
public void create()Creates lock file and, ifisDirectoryset 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.
-