19 package org.sleuthkit.datamodel;
21 import java.util.Collections;
22 import java.util.logging.Level;
23 import java.util.logging.Logger;
46 private long imageHandle = -1;
94 long dataSourceObjectId,
101 long ctime,
long crtime,
long atime,
long mtime,
106 Long osAccountObjId) {
108 super(db, objId, dataSourceObjectId, fileSystemObjectId,
TSK_FS_ATTR_TYPE_ENUM.
TSK_FS_ATTR_TYPE_DEFAULT, 0, name, fileType, 0L, 0, dirType, metaType, dirFlag, metaFlags, size, ctime, crtime, atime, mtime, (
short) 0, 0, 0, md5Hash, sha256Hash, sha1Hash, knownState, parentPath, mimeType,
SleuthkitCase.extractExtension(name), ownerUid, osAccountObjId,
TskData.
CollectedStatus.
UNKNOWN, Collections.emptyList());
121 Logger.getLogger(
LayoutFile.class.
getName()).log(Level.SEVERE, String.format(
"Error getting layout ranges for layout file (objId = %d)",
getId()), ex);
158 long offsetInThisLayoutContent = 0;
164 if (offset + readLen > size)
165 readLen = size - offset;
167 if (imageHandle == -1) {
169 if ((dataSource != null) && (dataSource instanceof
Image)) {
170 Image image = (Image) dataSource;
178 if (bytesRead < readLen) {
179 if (offset < offsetInThisLayoutContent + range.getByteLen()) {
180 long offsetInRange = 0;
181 if (bytesRead == 0) {
182 offsetInRange = offset - offsetInThisLayoutContent;
184 long offsetInImage = range.getByteStart() + offsetInRange;
185 long lenToReadInRange = Math.min(range.getByteLen() - offsetInRange, readLen - bytesRead);
186 int lenRead = readImgToOffset(imageHandle, buf, bytesRead, offsetInImage, (
int) lenToReadInRange);
187 bytesRead += lenRead;
188 if (lenToReadInRange != lenRead) {
192 offsetInThisLayoutContent += range.getByteLen();
216 private int readImgToOffset(
long imgHandle, byte[] buf,
int offsetInBuf,
long offsetInImage,
int lenToRead)
throws TskCoreException {
217 byte[] currentBuffer =
new byte[lenToRead];
219 System.arraycopy(currentBuffer, 0, buf, offsetInBuf, lenToRead);
232 public <T> T accept(ContentVisitor<T> visitor) {
233 return visitor.visit(
this);
245 public <T> T accept(SleuthkitItemVisitor<T> visitor) {
246 return visitor.visit(
this);
257 return super.toString(preserveState) +
"LayoutFile [\t" +
"]\t";
final TSK_FS_NAME_TYPE_ENUM dirType
static int readImg(long imgHandle, byte[] readBuffer, long offset, long len)
final Long fileSystemObjectId
final TskData.TSK_DB_FILES_TYPE_ENUM fileType
String toString(boolean preserveState)
TSK_FS_NAME_FLAG_ENUM dirFlag
Set< TSK_FS_META_FLAG_ENUM > metaFlags
int readInt(byte[] buf, long offset, long len)
TskData.FileKnown knownState
List< TskFileRange > getRanges()
final TSK_FS_META_TYPE_ENUM metaType
synchronized long getImageHandle()