Class TemporaryFileDirectory

java.lang.Object
velox.api.layer1.common.temporaryfiles.TemporaryFileDirectory

public class TemporaryFileDirectory extends Object
Manages a directory reserved for temporary resources. Required, because all temp resources need an associated lock.

Reasons:

  • Temp directories are pruned at Bookmap startup and shutdown.
  • There might be multiple instances of Bookmap running simultaneously over the same settings dir (dev environment only).
  • On user machines, there might be background threads that still use the resources at the time of shutdown. Unexpected deletion of those resources can lead to permanent corruption.
  • Lock ensures that only unused resources will be pruned.

Typical usage pattern:


 TempPath tempPath = TemporaryFileDirectory.DEFAULT.newTempPath(...);
 Path path = tempPath.get(); // or tempPath.createDirectory()
 // use the path
 tempPath.dispose();
 

TempPath can also be used with try-with-resources.