use of org.pentaho.platform.api.util.ITempFileDeleter in project pentaho-platform by pentaho.
the class ApplicationContextDouble method createTempFile.
public File createTempFile(final IPentahoSession session, final String prefix, final String extn, final File parentDir, boolean trackFile) throws IOException {
ITempFileDeleter fileDeleter = null;
if ((session != null) && trackFile) {
fileDeleter = (ITempFileDeleter) session.getAttribute(ITempFileDeleter.DELETER_SESSION_VARIABLE);
}
final String newPrefix = new StringBuilder().append(prefix).append(session.getId().substring(0, 10)).append('-').toString();
final File file = File.createTempFile(newPrefix, extn, parentDir);
if (fileDeleter != null) {
fileDeleter.trackTempFile(file);
} else {
// There is no deleter, so cleanup on VM exit. (old behavior)
file.deleteOnExit();
}
return file;
}
Aggregations