19 package org.sleuthkit.autopsy.ingest;
21 import java.util.List;
22 import java.util.logging.Level;
39 final class GetFilesCountVisitor
extends ContentVisitor.Default<Long> {
41 private static final Logger logger = Logger.getLogger(GetFilesCountVisitor.class.getName());
44 public Long
visit(FileSystem fs) {
47 SleuthkitCase sc = Case.getCurrentCase().getSleuthkitCase();
48 StringBuilder queryB =
new StringBuilder();
49 queryB.append(
"( (fs_obj_id = ").append(fs.getId());
52 queryB.append(
" AND ( (meta_type = ").append(TskData.TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_REG.getValue());
53 queryB.append(
") OR (meta_type = ").append(TskData.TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_DIR.getValue());
54 queryB.append(
") OR (meta_type = ").append(TskData.TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_VIRT.getValue());
55 queryB.append(
" AND (name != '.') AND (name != '..')");
61 final String query = queryB.toString();
62 logger.log(Level.INFO,
"Executing count files query: {0}", query);
63 return sc.countFilesWhere(query);
64 }
catch (TskCoreException ex) {
65 logger.log(Level.SEVERE,
"Couldn't get count of all files in FileSystem", ex);
71 public Long
visit(LayoutFile lf) {
77 private long getCountFromChildren(Content content) {
80 List<Content> children = content.getChildren();
81 if (children.size() > 0) {
82 for (Content child : children) {
83 count += child.accept(
this);
88 }
catch (TskCoreException ex) {
89 logger.log(Level.WARNING,
"Could not get count of objects from children to get num of total files to be ingested", ex);
95 protected Long defaultVisit(Content cntnt) {
98 return getCountFromChildren(cntnt);