Skip to content

Commit

Permalink
'#1985: Set a custom file name and extension for carved resume.dat.
Browse files Browse the repository at this point in the history
  • Loading branch information
wladimirleite committed Nov 17, 2023
1 parent e8f7369 commit 8d30398
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Map;

public class ResumeDatCarver extends TorrentCarver {
@Override
public boolean isValid(Map<String, Object> dict) {
for (String key : dict.keySet()) {
Object value = dict.get(key);
Expand All @@ -16,4 +17,14 @@ public boolean isValid(Map<String, Object> dict) {
}
return false;
}

@Override
protected String getCarvedNamePrefix() {
return "Carved-Resume-";
}

@Override
protected String getCarvedNameSuffix() {
return ".dat";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import iped.properties.MediaTypes;

public abstract class AbstractCarver implements Carver {
protected static String carvedNamePrefix = "Carved-";// esta propriedade não foi declarada estatica para permitir
protected CarverType[] carverTypes = null;

protected ArrayDeque<Hit> headersWaitingFooters = new ArrayDeque<>();
Expand Down Expand Up @@ -99,7 +98,7 @@ public IItem carveFromHeader(IItem parentEvidence, Hit header, long len) throws
if ((!ignoreCorrupted && !isSpecificIgnoreCorrupted()) || isValid(parentEvidence, header, len)) {
IItem offsetFile = parentEvidence.createChildItem();

String name = carvedNamePrefix + header.getOffset();
String name = getCarvedNamePrefix() + header.getOffset() + getCarvedNameSuffix();
offsetFile.setName(name);
offsetFile.setPath(parentEvidence.getPath() + ">>" + name);

Expand Down Expand Up @@ -150,7 +149,23 @@ public IItem carveFromFooter(IItem parentEvidence, Hit footer) throws IOExceptio

return null;
}

/**
* @return The prefix to be used in carved item name. Use a function to allow
* overriding.
*/
protected String getCarvedNamePrefix() {
return "Carved-";
}

/**
* @return The suffix to be used in carved item name. Default is an empty
* string.
*/
protected String getCarvedNameSuffix() {
return "";
}

public boolean isValid(IItem parentEvidence, Hit headerOffset, long length) {
try {
// tenta parsear o conteudo
Expand Down

0 comments on commit 8d30398

Please sign in to comment.