From f1d4222279b2dce6ed5ab2fbd7dbb28245e57b35 Mon Sep 17 00:00:00 2001 From: phrack Date: Mon, 22 Aug 2016 07:37:45 -0400 Subject: [PATCH] Remove Windows OpenCV cleanup hack because the delete on close but is fixed --- src/main/java/com/shootoff/Main.java | 34 ---------------------------- 1 file changed, 34 deletions(-) diff --git a/src/main/java/com/shootoff/Main.java b/src/main/java/com/shootoff/Main.java index 58bb179a..6c53354a 100644 --- a/src/main/java/com/shootoff/Main.java +++ b/src/main/java/com/shootoff/Main.java @@ -759,40 +759,6 @@ public static void main(String[] args) { if ("Mac OS X".equals(os)) { nu.pattern.OpenCV.loadShared(); Camera.getDefault(); - } else if (os.startsWith("Windows")) { - // OpenPNP's OpenCV wrapper for Java does not properly clean up - // after itself on Windows, thus it can fill the drive with - // stale temporary files. This hack works around the problem - // by giving ShootOFF on Windows its own instance of a temp - // directory that we can safely purge of stale files at - // the start of each session. - System.setProperty("java.io.tmpdir", System.getProperty("user.dir") + File.separator + "temp_bins"); - - final File tempBinsDir = new File(System.getProperty("java.io.tmpdir")); - - if (tempBinsDir.exists()) { - try { - Files.walkFileTree(tempBinsDir.toPath(), new SimpleFileVisitor() { - @Override - public FileVisitResult postVisitDirectory(final Path dir, final IOException e) - throws IOException { - if (!Files.isSameFile(tempBinsDir.toPath(), dir)) Files.deleteIfExists(dir); - return super.postVisitDirectory(dir, e); - } - - @Override - public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) - throws IOException { - Files.deleteIfExists(file); - return super.visitFile(file, attrs); - } - }); - } catch (IOException e) { - logger.error("Failed walk temp_bins to delete old folders."); - } - } else if (!tempBinsDir.mkdir()) { - logger.error("Failed to create temporary directory to store ShootOFF binaries."); - } } else if (os.startsWith("Linux")) { // Need to ensure v4l1compat is preloaded if it exists otherwise // OpenCV won't work