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;
91 long dataSourceObjectId,
97 long ctime,
long crtime,
long atime,
long mtime,
101 Long osAccountObjId) {
103 super(db, objId, dataSourceObjectId,
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, knownState, parentPath, mimeType,
SleuthkitCase.extractExtension(name), ownerUid, osAccountObjId, Collections.emptyList());
116 Logger.getLogger(
LayoutFile.class.
getName()).log(Level.SEVERE, String.format(
"Error getting layout ranges for layout file (objId = %d)",
getId()), ex);
153 long offsetInThisLayoutContent = 0;
159 if (offset + readLen > size)
160 readLen = size - offset;
162 if (imageHandle == -1) {
164 if ((dataSource != null) && (dataSource instanceof
Image)) {
165 Image image = (Image) dataSource;
173 if (bytesRead < readLen) {
174 if (offset < offsetInThisLayoutContent + range.getByteLen()) {
175 long offsetInRange = 0;
176 if (bytesRead == 0) {
177 offsetInRange = offset - offsetInThisLayoutContent;
179 long offsetInImage = range.getByteStart() + offsetInRange;
180 long lenToReadInRange = Math.min(range.getByteLen() - offsetInRange, readLen - bytesRead);
181 int lenRead = readImgToOffset(imageHandle, buf, bytesRead, offsetInImage, (
int) lenToReadInRange);
182 bytesRead += lenRead;
183 if (lenToReadInRange != lenRead) {
187 offsetInThisLayoutContent += range.getByteLen();
211 private int readImgToOffset(
long imgHandle, byte[] buf,
int offsetInBuf,
long offsetInImage,
int lenToRead)
throws TskCoreException {
212 byte[] currentBuffer =
new byte[lenToRead];
214 System.arraycopy(currentBuffer, 0, buf, offsetInBuf, lenToRead);
227 public <T> T accept(ContentVisitor<T> visitor) {
228 return visitor.visit(
this);
240 public <T> T accept(SleuthkitItemVisitor<T> visitor) {
241 return visitor.visit(
this);
252 return super.toString(preserveState) +
"LayoutFile [\t" +
"]\t";
284 @SuppressWarnings(
"deprecation")
289 long size, String md5Hash,
FileKnown knownState, String parentPath) {
290 this(db, objId, db.getDataSourceObjectId(objId), name,
fileType,
dirType,
metaType,
dirFlag,
metaFlags,
size, 0L, 0L, 0L, 0L,
md5Hash, null,
knownState,
parentPath, null,
OsAccount.NO_OWNER_ID,
OsAccount.NO_ACCOUNT);
final TSK_FS_NAME_TYPE_ENUM dirType
static int readImg(long imgHandle, byte[] readBuffer, long offset, long len)
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()