19 package org.sleuthkit.autopsy.modules.interestingitems;
22 import java.io.FileInputStream;
23 import java.io.FileOutputStream;
24 import java.io.IOException;
25 import java.io.Serializable;
26 import java.nio.file.Path;
27 import java.nio.file.Paths;
28 import java.util.HashMap;
30 import org.openide.util.io.NbObjectInputStream;
31 import org.openide.util.io.NbObjectOutputStream;
37 class FileSetsDefinitions
implements Serializable {
39 private static final long serialVersionUID = 1L;
41 private final Map<String, FilesSet> filesSets;
43 FileSetsDefinitions(Map<String, FilesSet> filesSets) {
44 this.filesSets = filesSets;
50 Map<String, FilesSet> getFilesSets() {
63 File outputPath = Paths.get(basePath, fileName).toFile();
64 outputPath.getParentFile().mkdirs();
65 try (
final NbObjectOutputStream out =
new NbObjectOutputStream(
new FileOutputStream(outputPath))) {
66 out.writeObject(
new FileSetsDefinitions(interestingFilesSets));
67 }
catch (IOException ex) {
85 Path filePath = Paths.get(basePath, serialFileName);
86 File fileSetFile = filePath.toFile();
87 String filePathStr = filePath.toString();
88 if (fileSetFile.exists()) {
90 try (
final NbObjectInputStream in =
new NbObjectInputStream(
new FileInputStream(filePathStr))) {
91 FileSetsDefinitions filesSetsSettings = (FileSetsDefinitions) in.readObject();
92 return filesSetsSettings.getFilesSets();
94 }
catch (IOException | ClassNotFoundException ex) {
98 return new HashMap<>();