Autopsy 4.22.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
GetFilesContentVisitor.java
Go to the documentation of this file.
1/*
2 * Autopsy Forensic Browser
3 *
4 * Copyright 2011-2018 Basis Technology Corp.
5 * Contact: carrier <at> sleuthkit <dot> org
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19package org.sleuthkit.autopsy.ingest;
20
21import java.util.ArrayList;
22import java.util.Collection;
23import java.util.logging.Level;
24import org.sleuthkit.autopsy.coreutils.Logger;
25import org.sleuthkit.datamodel.AbstractContent;
26import org.sleuthkit.datamodel.Content;
27import org.sleuthkit.datamodel.ContentVisitor;
28import org.sleuthkit.datamodel.Directory;
29import org.sleuthkit.datamodel.AbstractFile;
30import org.sleuthkit.datamodel.Image;
31import org.sleuthkit.datamodel.VirtualDirectory;
32import org.sleuthkit.datamodel.LocalDirectory;
33import org.sleuthkit.datamodel.Pool;
34import org.sleuthkit.datamodel.Report;
35import org.sleuthkit.datamodel.TskException;
36import org.sleuthkit.datamodel.Volume;
37import org.sleuthkit.datamodel.VolumeSystem;
38
42abstract class GetFilesContentVisitor implements ContentVisitor<Collection<AbstractFile>> {
43
44 private static final Logger logger = Logger.getLogger(GetFilesContentVisitor.class.getName());
45
46 @Override
47 public Collection<AbstractFile> visit(VirtualDirectory ld) {
48 return getAllFromChildren(ld);
49 }
50
51 @Override
52 public Collection<AbstractFile> visit(LocalDirectory ld) {
53 return getAllFromChildren(ld);
54 }
55
56 @Override
57 public Collection<AbstractFile> visit(Directory drctr) {
58 return getAllFromChildren(drctr);
59 }
60
61 @Override
62 public Collection<AbstractFile> visit(Image image) {
63 return getAllFromChildren(image);
64 }
65
66 @Override
67 public Collection<AbstractFile> visit(Volume volume) {
68 return getAllFromChildren(volume);
69 }
70
71 @Override
72 public Collection<AbstractFile> visit(VolumeSystem vs) {
73 return getAllFromChildren(vs);
74 }
75
76 @Override
77 public Collection<AbstractFile> visit(Pool pool) {
78 return getAllFromChildren(pool);
79 }
80
81 @Override
82 public Collection<AbstractFile> visit(Report r) {
83 return getAllFromChildren(r);
84 }
85
94 protected Collection<AbstractFile> getAllFromChildren(Content parent) {
95 Collection<AbstractFile> all = new ArrayList<>();
96
97 try {
98 for (Content child : parent.getChildren()) {
99 if (child instanceof AbstractContent){
100 all.addAll(child.accept(this));
101 }
102 }
103 } catch (TskException ex) {
104 logger.log(Level.SEVERE, "Error getting Content children", ex); //NON-NLS
105 }
106
107 return all;
108 }
109}

Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.