in java/main/src/main/java/com/epam/deltix/utilities/FileJanitor.java [113:141]
public static boolean tryDeleteDirectory(final Path dir) {
boolean isSuccess = false;
final LockFile lock = tryCreateLockFile(dir);
if (null == lock)
return false;
try {
final List<FileLock> openedFiles = new ArrayList<>();
final List<Path> foundFiles = new ArrayList<>();
isSuccess = listDeletable(dir, openedFiles, foundFiles);
for (final FileLock fl : openedFiles)
closeLockedFileChannel(fl);
if (isSuccess) {
for (final Path path : foundFiles) {
if (!isLockFile(path) && !tryDelete(path))
return false;
}
}
} catch (final IOException ignored) {
} finally {
lock.close();
}
return isSuccess ? tryDelete(dir) : false;
}