19 package org.sleuthkit.autopsy.datasourceprocessors.xry;
21 import java.io.IOException;
22 import java.io.UncheckedIOException;
23 import java.nio.file.Files;
24 import java.nio.file.LinkOption;
25 import java.nio.file.Path;
26 import java.nio.file.attribute.BasicFileAttributes;
27 import java.util.ArrayList;
28 import java.util.Iterator;
29 import java.util.List;
30 import java.util.stream.Stream;
35 final class XRYFolder {
39 private static final int XRY_FILES_DEPTH = 1;
42 private final Path xryFolderPath;
44 public XRYFolder(Path folder) {
45 xryFolderPath = folder;
56 public List<Path> getNonXRYFiles() throws IOException {
57 try (Stream<Path> allFiles = Files.walk(xryFolderPath, XRY_FILES_DEPTH)) {
58 List<Path> otherFiles =
new ArrayList<>();
59 Iterator<Path> allFilesIterator = allFiles.iterator();
60 while (allFilesIterator.hasNext()) {
61 Path currentPath = allFilesIterator.next();
62 if (!currentPath.equals(xryFolderPath)
63 && !XRYFileReader.isXRYFile(currentPath)) {
64 otherFiles.add(currentPath);
68 }
catch (UncheckedIOException ex) {
80 public List<XRYFileReader> getXRYFileReaders() throws IOException {
81 try (Stream<Path> allFiles = Files.walk(xryFolderPath, XRY_FILES_DEPTH)) {
82 List<XRYFileReader> fileReaders =
new ArrayList<>();
84 Iterator<Path> allFilesIterator = allFiles.iterator();
85 while (allFilesIterator.hasNext()) {
86 Path currentFile = allFilesIterator.next();
87 if (XRYFileReader.isXRYFile(currentFile)) {
88 fileReaders.add(
new XRYFileReader(currentFile));
92 }
catch (UncheckedIOException ex) {
112 public static boolean isXRYFolder(Path folder)
throws IOException {
113 BasicFileAttributes attr = Files.readAttributes(folder,
114 BasicFileAttributes.class, LinkOption.NOFOLLOW_LINKS);
116 if (!attr.isDirectory()) {
121 try (Stream<Path> allFiles = Files.walk(folder, XRY_FILES_DEPTH)) {
122 Iterator<Path> allFilesIterator = allFiles.iterator();
123 while (allFilesIterator.hasNext()) {
124 Path currentFile = allFilesIterator.next();
125 if (XRYFileReader.isXRYFile(currentFile)) {
131 }
catch (UncheckedIOException ex) {