Skip to content
Snippets Groups Projects
Commit b0d8ef50 authored by Brian Carrier's avatar Brian Carrier
Browse files

Merge pull request #78 from adam-m/master

java bindings add getUniquePath() to FsContent
parents fed9b1a9 55b623ad
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,7 @@
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;
import org.sleuthkit.datamodel.TskData.FileKnown;
/**
......@@ -39,6 +40,11 @@ public abstract class FsContent extends AbstractFile {
*/
protected String parent_path;
/*
* Unique path containing image and volume
*/
protected String unique_path;
/*
* md5 hash
*/
......@@ -389,6 +395,44 @@ public String getParentPath() {
return this.parent_path;
}
/**
* Get the absolute unique across all files in the case
* parent path string of this FsContent
* The path contains image and volume-system partition
* After first call, every subsequent call returns the cached string
* @return unique absolute file path (cached after first call)
* @throws TskCoreException thrown when critical error occurred in Tsk Core
* and unique absolute path could not be queried
*/
public String getUniquePath() throws TskCoreException {
if (unique_path != null) {
return unique_path;
}
StringBuilder sb = new StringBuilder();
//prepend image and volume to file path
Image image = this.getImage();
StringTokenizer tok = new StringTokenizer(image.getName(), "/\\");
String imageName = null;
while (tok.hasMoreTokens()) {
imageName = tok.nextToken();
}
sb.append("/").append(imageName);
if (parentFileSystem != null) {
Content vol = parentFileSystem.getParent();
if (vol != null
&& ! vol.equals(image)) {
sb.append("/");
sb.append(vol.getName());
}
}
sb.append(getParentPath());
unique_path = sb.toString();
return unique_path;
}
/**
* Get the md5 hash value as calculated, if present
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment