19 package org.sleuthkit.autopsy.ingest;
21 import java.util.List;
22 import java.util.logging.Level;
40 final class GetFilesCountVisitor
extends ContentVisitor.Default<Long> {
42 private static final Logger logger = Logger.getLogger(GetFilesCountVisitor.class.getName());
45 public Long visit(FileSystem fs) {
50 sc = Case.getCurrentCaseThrows().getSleuthkitCase();
51 }
catch (NoCurrentCaseException ex) {
52 logger.log(Level.SEVERE,
"Exception while getting open case.", ex);
55 StringBuilder queryB =
new StringBuilder();
56 queryB.append(
"( (fs_obj_id = ").append(fs.getId());
59 queryB.append(
" AND ( (meta_type = ").append(TskData.TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_REG.getValue());
60 queryB.append(
") OR (meta_type = ").append(TskData.TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_DIR.getValue());
61 queryB.append(
") OR (meta_type = ").append(TskData.TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_VIRT_DIR.getValue());
62 queryB.append(
") OR (meta_type = ").append(TskData.TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_VIRT.getValue());
63 queryB.append(
" AND (name != '.') AND (name != '..')");
69 final String query = queryB.toString();
70 return sc.countFilesWhere(query);
71 }
catch (TskCoreException ex) {
72 logger.log(Level.SEVERE,
"Couldn't get count of all files in FileSystem", ex);
78 public Long visit(LayoutFile lf) {
84 private long getCountFromChildren(Content content) {
87 List<Content> children = content.getChildren();
88 if (children.size() > 0) {
89 for (Content child : children) {
90 count += child.accept(
this);
95 }
catch (TskCoreException ex) {
96 logger.log(Level.WARNING,
"Could not get count of objects from children to get num of total files to be ingested", ex);
102 protected Long defaultVisit(Content cntnt) {
105 return getCountFromChildren(cntnt);