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

Merge pull request #195 from adam-m/master

add new method to get data source for file easily
parents 53234549 a56e0735
Branches
Tags
No related merge requests found
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
public abstract class AbstractContent implements Content { public abstract class AbstractContent implements Content {
public final static long UNKNOWN_ID = -1; public final static long UNKNOWN_ID = -1;
private SleuthkitCase db; private final SleuthkitCase db;
private long objId; private long objId;
private String name; private String name;
private Content parent; private Content parent;
......
...@@ -2618,6 +2618,29 @@ private long getFileSystemByFileId(long fileId) { ...@@ -2618,6 +2618,29 @@ private long getFileSystemByFileId(long fileId) {
} }
return ret; return ret;
} }
/**
* Gets the root-level data source object id
* (such as Image or VirtualDirectory representing filesets) for the file
* @param file file to get the root-level object id for
* @return the root content object id in the hierarchy, or -1 if not found (such as when invalid file object passed in)
* @throws TskCoreException thrown if check failed due to a critical tsk error
*/
public long getFileDataSource(AbstractFile file) throws TskCoreException {
final Image image = file.getImage();
if (image != null) {
//case for image data source
return image.getId();
}
else {
//otherwise, get the root non-image data source id
//note, we are currently using fs_id internally to store data source id for such files
return getFileSystemByFileId(file.getId());
}
}
/** /**
* Checks if the file is a (sub)child of the data source (parentless Content object * Checks if the file is a (sub)child of the data source (parentless Content object
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment