Skip to content

Commit

Permalink
Remove Windows OpenCV cleanup hack because the delete on close but is…
Browse files Browse the repository at this point in the history
… fixed
  • Loading branch information
phrack committed Aug 22, 2016
1 parent 9337f30 commit f1d4222
Showing 1 changed file with 0 additions and 34 deletions.
34 changes: 0 additions & 34 deletions src/main/java/com/shootoff/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Path>() {
@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
Expand Down

0 comments on commit f1d4222

Please sign in to comment.