mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-14 08:56:15 +00:00
Fix extraction action for VirtDir and simplify. Remove no longer needed visitor.
This commit is contained in:
parent
556c5cde26
commit
35828bae1b
@ -38,6 +38,7 @@ import org.sleuthkit.datamodel.LayoutFile;
|
||||
import org.sleuthkit.datamodel.LocalFile;
|
||||
import org.sleuthkit.datamodel.ReadContentInputStream;
|
||||
import org.sleuthkit.datamodel.TskException;
|
||||
import org.sleuthkit.datamodel.VirtualDirectory;
|
||||
|
||||
/**
|
||||
* Static class of utility methods for Content objects
|
||||
@ -107,8 +108,7 @@ public final class ContentUtils {
|
||||
final Image image = c.getImage();
|
||||
if (image != null) {
|
||||
return TimeZone.getTimeZone(image.getTimeZone());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
//case such as top level VirtualDirectory
|
||||
return TimeZone.getDefault();
|
||||
}
|
||||
@ -135,7 +135,8 @@ public final class ContentUtils {
|
||||
private static final int TO_FILE_BUFFER_SIZE = 8192;
|
||||
|
||||
/**
|
||||
* Reads all the data from any content object and writes (extracts) it to a file.
|
||||
* Reads all the data from any content object and writes (extracts) it to a
|
||||
* file.
|
||||
*
|
||||
* @param content Any content object.
|
||||
* @param outputFile Will be created if it doesn't exist, and overwritten if
|
||||
@ -194,7 +195,7 @@ public final class ContentUtils {
|
||||
/**
|
||||
* Helper to ignore the '.' and '..' directories
|
||||
*/
|
||||
public static boolean isDotDirectory(Directory dir) {
|
||||
public static boolean isDotDirectory(AbstractFile dir) {
|
||||
String name = dir.getName();
|
||||
return name.equals(".") || name.equals("..");
|
||||
}
|
||||
@ -277,7 +278,7 @@ public final class ContentUtils {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Void visit(LocalFile lf) {
|
||||
try {
|
||||
@ -292,6 +293,21 @@ public final class ContentUtils {
|
||||
|
||||
@Override
|
||||
public Void visit(Directory dir) {
|
||||
return visitDir(dir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visit(VirtualDirectory dir) {
|
||||
return visitDir(dir);
|
||||
}
|
||||
|
||||
private java.io.File getFsContentDest(Content fsc) {
|
||||
String path = dest.getAbsolutePath() + java.io.File.separator
|
||||
+ fsc.getName();
|
||||
return new java.io.File(path);
|
||||
}
|
||||
|
||||
public Void visitDir(AbstractFile dir) {
|
||||
|
||||
// don't extract . and .. directories
|
||||
if (isDotDirectory(dir)) {
|
||||
@ -300,14 +316,13 @@ public final class ContentUtils {
|
||||
|
||||
dest.mkdir();
|
||||
|
||||
// member visitor to generate destination files for children
|
||||
DestFileContentVisitor destFileCV = new DestFileContentVisitor();
|
||||
|
||||
|
||||
try {
|
||||
int numProcessed = 0;
|
||||
// recurse on children
|
||||
for (Content child : dir.getChildren()) {
|
||||
java.io.File childFile = child.accept(destFileCV);
|
||||
java.io.File childFile = getFsContentDest(child);
|
||||
ExtractFscContentVisitor childVisitor =
|
||||
new ExtractFscContentVisitor(childFile, progress, worker, false);
|
||||
// If this is the source directory of an extract it
|
||||
@ -335,52 +350,5 @@ public final class ContentUtils {
|
||||
throw new UnsupportedOperationException("Can't extract a "
|
||||
+ cntnt.getClass().getSimpleName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper visitor to get the destination file for a child Content object
|
||||
*/
|
||||
private class DestFileContentVisitor extends ContentVisitor.Default<java.io.File> {
|
||||
|
||||
/**
|
||||
* Get destination file by adding File/Directory name to the path of
|
||||
* parent
|
||||
*/
|
||||
private java.io.File getFsContentDest(AbstractFile fsc) {
|
||||
String path = dest.getAbsolutePath() + java.io.File.separator
|
||||
+ fsc.getName();
|
||||
return new java.io.File(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.io.File visit(File f) {
|
||||
return getFsContentDest(f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.io.File visit(LayoutFile lf) {
|
||||
return getFsContentDest(lf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.io.File visit(DerivedFile df) {
|
||||
return getFsContentDest(df);
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.io.File visit(LocalFile lf) {
|
||||
return getFsContentDest(lf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.io.File visit(Directory dir) {
|
||||
return getFsContentDest(dir);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected java.io.File defaultVisit(Content cntnt) {
|
||||
throw new UnsupportedOperationException("Can't get destination file for a "
|
||||
+ cntnt.getClass().getSimpleName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user