mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-14 17:06:16 +00:00
file manager and visitor additions for local files
This commit is contained in:
parent
f66905831c
commit
14db785dd5
@ -100,101 +100,110 @@ public class FileManager implements Closeable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a derived file, adds it to the database and returns it.
|
* Creates a derived file, adds it to the database and returns it.
|
||||||
*
|
*
|
||||||
* @param fileName file name the derived file
|
* @param fileName file name the derived file
|
||||||
* @param localPath local path of the derived file, including the file name. The path is relative to the database path.
|
* @param localPath local path of the derived file, including the file name.
|
||||||
* @param size size of the derived file in bytes
|
* The path is relative to the database path.
|
||||||
|
* @param size size of the derived file in bytes
|
||||||
* @param ctime
|
* @param ctime
|
||||||
* @param crtime
|
* @param crtime
|
||||||
* @param atime
|
* @param atime
|
||||||
* @param mtime
|
* @param mtime
|
||||||
* @param isFile whether a file or directory, true if a file
|
* @param isFile whether a file or directory, true if a file
|
||||||
* @param parentFile the parent file object this the new file was derived from, either a fs file or parent derived file/dikr\\r
|
* @param parentFile the parent file object this the new file was derived
|
||||||
|
* from, either a fs file or parent derived file/dikr\\r
|
||||||
* @param rederiveDetails details needed to re-derive file (will be specific
|
* @param rederiveDetails details needed to re-derive file (will be specific
|
||||||
* to the derivation method), currently unused
|
* to the derivation method), currently unused
|
||||||
* @param toolName name of derivation method/tool, currently unused
|
* @param toolName name of derivation method/tool, currently unused
|
||||||
* @param toolVersion version of derivation method/tool, currently unused
|
* @param toolVersion version of derivation method/tool, currently unused
|
||||||
* @param otherDetails details of derivation method/tool, currently unused
|
* @param otherDetails details of derivation method/tool, currently unused
|
||||||
* @return newly created derived file object added to the database
|
* @return newly created derived file object added to the database
|
||||||
* @throws TskCoreException exception thrown if the object creation failed
|
* @throws TskCoreException exception thrown if the object creation failed
|
||||||
* due to a critical system error or of the file manager has already been closed
|
* due to a critical system error or of the file manager has already been
|
||||||
*
|
* closed
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public synchronized DerivedFile addDerivedFile(String fileName, String localPath, long size,
|
public synchronized DerivedFile addDerivedFile(String fileName, String localPath, long size,
|
||||||
long ctime, long crtime, long atime, long mtime,
|
long ctime, long crtime, long atime, long mtime,
|
||||||
boolean isFile, AbstractFile parentFile,
|
boolean isFile, AbstractFile parentFile,
|
||||||
String rederiveDetails, String toolName, String toolVersion, String otherDetails) throws TskCoreException {
|
String rederiveDetails, String toolName, String toolVersion, String otherDetails) throws TskCoreException {
|
||||||
|
|
||||||
if (tskCase == null) {
|
if (tskCase == null) {
|
||||||
throw new TskCoreException("Attempted to use FileManager after it was closed.");
|
throw new TskCoreException("Attempted to use FileManager after it was closed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return tskCase.addDerivedFile(fileName, localPath, size,
|
return tskCase.addDerivedFile(fileName, localPath, size,
|
||||||
ctime, crtime, atime, mtime,
|
ctime, crtime, atime, mtime,
|
||||||
isFile, parentFile, rederiveDetails, toolName, toolVersion, otherDetails);
|
isFile, parentFile, rederiveDetails, toolName, toolVersion, otherDetails);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a single local file under $LocalFiles for the case, adds it to the database and returns it.
|
* Creates a single local file under $LocalFiles for the case, adds it to
|
||||||
*
|
* the database and returns it.
|
||||||
* @param fileName file name the derived file
|
*
|
||||||
* @param localPath local path of the derived file, including the file name. The path is relative to the database path.
|
* @param localAbsPath local absolute path of the local file, including the
|
||||||
* @param size size of the derived file in bytes
|
* file name.
|
||||||
* @param ctime
|
* @return newly created local file object added to the database
|
||||||
* @param crtime
|
* @throws TskCoreException exception thrown if the object creation failed
|
||||||
* @param atime
|
* due to a critical system error or of the file manager has already been
|
||||||
* @param mtime
|
* closed
|
||||||
* @param isFile whether a file or directory, true if a file
|
*
|
||||||
* @return newly created local file object added to the database
|
|
||||||
* @throws TskCoreException exception thrown if the object creation failed
|
|
||||||
* due to a critical system error or of the file manager has already been closed
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public synchronized LocalFile addLocalFileSingle(String fileName, String localPath, long size,
|
public synchronized LocalFile addLocalFileSingle(String localAbsPath) throws TskCoreException {
|
||||||
long ctime, long crtime, long atime, long mtime,
|
|
||||||
boolean isFile) throws TskCoreException {
|
|
||||||
|
|
||||||
if (tskCase == null) {
|
if (tskCase == null) {
|
||||||
throw new TskCoreException("Attempted to use FileManager after it was closed.");
|
throw new TskCoreException("Attempted to use FileManager after it was closed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return tskCase.addLocalFile(fileName, localPath, size,
|
return addLocalFileSingle(localAbsPath, null);
|
||||||
ctime, crtime, atime, mtime,
|
|
||||||
isFile, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/**
|
* Creates a single local file under parentFile for the case, adds it to the
|
||||||
* Creates a single local file under parentFile for the case, adds it to the database and returns it.
|
* database and returns it.
|
||||||
*
|
*
|
||||||
* @param fileName file name the derived file
|
* @param localAbsPath local absolute path of the local file, including the
|
||||||
* @param localPath local path of the derived file, including the file name. The path is relative to the database path.
|
* file name
|
||||||
* @param size size of the derived file in bytes
|
* @param parentFile parent file object (such as virtual directory, another
|
||||||
* @param ctime
|
* local file, or fscontent File),
|
||||||
* @param crtime
|
* @return newly created local file object added to the database
|
||||||
* @param atime
|
* @throws TskCoreException exception thrown if the object creation failed
|
||||||
* @param mtime
|
* due to a critical system error or of the file manager has already been
|
||||||
* @param isFile whether a file or directory, true if a file
|
* closed
|
||||||
* @param parentFile parent file object (such as virtual directory, another local file, or fscontent File),
|
*
|
||||||
* @return newly created local file object added to the database
|
|
||||||
* @throws TskCoreException exception thrown if the object creation failed
|
|
||||||
* due to a critical system error or of the file manager has already been closed
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public synchronized LocalFile addLocalFileSingle(String fileName, String localPath, long size,
|
public synchronized LocalFile addLocalFileSingle(String localAbsPath, AbstractFile parentFile) throws TskCoreException {
|
||||||
long ctime, long crtime, long atime, long mtime,
|
|
||||||
boolean isFile, AbstractFile parentFile) throws TskCoreException {
|
|
||||||
|
|
||||||
if (tskCase == null) {
|
if (tskCase == null) {
|
||||||
throw new TskCoreException("Attempted to use FileManager after it was closed.");
|
throw new TskCoreException("Attempted to use FileManager after it was closed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return tskCase.addLocalFile(fileName, localPath, size,
|
java.io.File localFile = new java.io.File(localAbsPath);
|
||||||
|
if (!localFile.exists()) {
|
||||||
|
throw new TskCoreException("Attempted to add a local file that does not exist: " + localAbsPath);
|
||||||
|
}
|
||||||
|
if (!localFile.canRead()) {
|
||||||
|
throw new TskCoreException("Attempted to add a local file that is not readable: " + localAbsPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
long size = localFile.length();
|
||||||
|
boolean isFile = localFile.isFile();
|
||||||
|
|
||||||
|
//TODO what should do with mac times?
|
||||||
|
long ctime = 0;
|
||||||
|
long crtime = 0;
|
||||||
|
long atime = 0;
|
||||||
|
long mtime = 0;
|
||||||
|
|
||||||
|
String fileName = localFile.getName();
|
||||||
|
|
||||||
|
return tskCase.addLocalFile(fileName, localAbsPath, size,
|
||||||
ctime, crtime, atime, mtime,
|
ctime, crtime, atime, mtime,
|
||||||
isFile, parentFile);
|
isFile, parentFile);
|
||||||
|
|
||||||
|
//TODO decide if send event to viewers, or client should
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void close() throws IOException {
|
public synchronized void close() throws IOException {
|
||||||
tskCase = null;
|
tskCase = null;
|
||||||
|
@ -28,6 +28,7 @@ import org.sleuthkit.datamodel.Directory;
|
|||||||
import org.sleuthkit.datamodel.File;
|
import org.sleuthkit.datamodel.File;
|
||||||
import org.sleuthkit.datamodel.Image;
|
import org.sleuthkit.datamodel.Image;
|
||||||
import org.sleuthkit.datamodel.LayoutFile;
|
import org.sleuthkit.datamodel.LayoutFile;
|
||||||
|
import org.sleuthkit.datamodel.LocalFile;
|
||||||
import org.sleuthkit.datamodel.SleuthkitItemVisitor;
|
import org.sleuthkit.datamodel.SleuthkitItemVisitor;
|
||||||
import org.sleuthkit.datamodel.SleuthkitVisitableItem;
|
import org.sleuthkit.datamodel.SleuthkitVisitableItem;
|
||||||
import org.sleuthkit.datamodel.TskException;
|
import org.sleuthkit.datamodel.TskException;
|
||||||
@ -97,6 +98,11 @@ abstract class AbstractContentChildren<T> extends Keys<T> {
|
|||||||
return new LocalFileNode(df);
|
return new LocalFileNode(df);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AbstractContentNode visit(LocalFile lf) {
|
||||||
|
return new LocalFileNode(lf);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AbstractContentNode visit(VirtualDirectory ld) {
|
public AbstractContentNode visit(VirtualDirectory ld) {
|
||||||
return new VirtualDirectoryNode(ld);
|
return new VirtualDirectoryNode(ld);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user