23 package org.sleuthkit.autopsy.casemodule.services;
25 import java.io.Closeable;
26 import java.io.IOException;
27 import java.util.ArrayList;
28 import java.util.List;
29 import java.util.logging.Level;
30 import org.openide.util.NbBundle;
64 private synchronized void init() {
66 List<VirtualDirectory> virtRoots;
76 logger.log(Level.SEVERE,
"Error initializing FileManager and getting number of local file sets");
94 if (tskCase == null) {
95 throw new TskCoreException(NbBundle.getMessage(
this.getClass(),
"FileManager.findFiles.exception.msg"));
97 return tskCase.
findFiles(dataSource, fileName);
115 if (tskCase == null) {
116 throw new TskCoreException(NbBundle.getMessage(
this.getClass(),
"FileManager.findFiles2.exception.msg"));
118 return tskCase.
findFiles(dataSource, fileName, dirName);
135 if (tskCase == null) {
136 throw new TskCoreException(NbBundle.getMessage(
this.getClass(),
"FileManager.findFiles3.exception.msg"));
138 return findFiles(dataSource, fileName, parentFile.getName());
150 if (tskCase == null) {
151 throw new TskCoreException(NbBundle.getMessage(
this.getClass(),
"FileManager.openFiles.exception.msg"));
153 return tskCase.
openFiles(dataSource, filePath);
187 long ctime,
long crtime,
long atime,
long mtime,
189 String rederiveDetails, String toolName, String toolVersion, String otherDetails)
throws TskCoreException {
191 if (tskCase == null) {
192 throw new TskCoreException(NbBundle.getMessage(
this.getClass(),
"FileManager.addDerivedFile.exception.msg"));
196 ctime, crtime, atime, mtime,
197 isFile, parentFile, rederiveDetails, toolName, toolVersion, otherDetails);
216 if (tskCase == null) {
217 throw new TskCoreException(NbBundle.getMessage(
this.getClass(),
"FileManager.addCarvedFile.exception.msg"));
220 return tskCase.
addCarvedFile(carvedFileName, carvedFileSize, systemId, sectors);
232 if (tskCase == null) {
233 throw new TskCoreException(NbBundle.getMessage(
this.getClass(),
"FileManager.addCarvedFile.exception.msg"));
273 final List<java.io.File> rootsToAdd =
new ArrayList<>();
275 for (String absPath : localAbsPaths) {
276 java.io.File localFile =
new java.io.File(absPath);
277 if (!localFile.exists() || !localFile.canRead()) {
278 String msg = NbBundle
279 .getMessage(this.getClass(),
"FileManager.addLocalFilesDirs.exception.notReadable.msg",
280 localFile.getAbsolutePath());
281 logger.log(Level.SEVERE, msg);
284 rootsToAdd.add(localFile);
293 for (java.io.File localRootToAdd : rootsToAdd) {
296 if (localFileAdded == null) {
297 String msg = NbBundle
298 .getMessage(this.getClass(),
"FileManager.addLocalFilesDirs.exception.cantAdd.msg",
299 localRootToAdd.getAbsolutePath());
300 logger.log(Level.SEVERE, msg);
316 return fileSetRootDir;
331 int newFileSetCount = curNumFileSets + 1;
336 curNumFileSets = newFileSetCount;
338 String msg = NbBundle
339 .getMessage(this.getClass(),
"FileManager.addLocalFileSetRootDir.exception.errCreateDir.msg",
341 logger.log(Level.SEVERE, msg, ex);
364 if (tskCase == null) {
366 NbBundle.getMessage(
this.getClass(),
"FileManager.addLocalDirInt.exception.closed.msg"));
370 if (!localFile.exists()) {
372 NbBundle.getMessage(
this.getClass(),
"FileManager.addLocalDirInt.exception.doesntExist.msg",
373 localFile.getAbsolutePath()));
375 if (!localFile.canRead()) {
377 NbBundle.getMessage(
this.getClass(),
"FileManager.addLocalDirInt.exception.notReadable.msg",
378 localFile.getAbsolutePath()));
382 if (localFile.isDirectory()) {
385 if (childVd != null && addProgressUpdater != null) {
386 addProgressUpdater.fileAdded(childVd);
389 final java.io.File[] childrenFiles = localFile.
listFiles();
390 if (childrenFiles != null) {
391 for (java.io.File childFile : childrenFiles) {
419 if (tskCase == null) {
421 NbBundle.getMessage(
this.getClass(),
"FileManager.addLocalDirInt2.exception.closed.msg"));
424 long size = localFile.length();
425 boolean isFile = localFile.isFile();
432 String fileName = localFile.getName();
435 ctime, crtime, atime, mtime,
436 isFile, parentFile, trans);
442 public synchronized void close() throws IOException {
synchronized void close()
DerivedFile addDerivedFile(String fileName, String localPath, long size, long ctime, long crtime, long atime, long mtime, boolean isFile, AbstractFile parentFile, String rederiveDetails, String toolName, String toolVersion, String otherDetails)
synchronized List< AbstractFile > findFiles(Content dataSource, String fileName, AbstractFile parentFile)
CaseDbTransaction beginTransaction()
LocalFile addLocalFile(String fileName, String localPath, long size, long ctime, long crtime, long atime, long mtime, boolean isFile, AbstractFile parent)
VirtualDirectory addLocalFileSetRootDir(CaseDbTransaction trans)
List< AbstractFile > openFiles(Content dataSource, String filePath)
void fileAdded(AbstractFile newFile)
List< VirtualDirectory > getVirtualDirectoryRoots()
synchronized VirtualDirectory addLocalFilesDirs(List< String > localAbsPaths, FileAddProgressUpdater addProgressUpdater)
synchronized List< AbstractFile > findFiles(Content dataSource, String fileName)
List< LayoutFile > addCarvedFiles(List< CarvedFileContainer > filesToAdd)
synchronized DerivedFile addDerivedFile(String fileName, String localPath, long size, long ctime, long crtime, long atime, long mtime, boolean isFile, AbstractFile parentFile, String rederiveDetails, String toolName, String toolVersion, String otherDetails)
AbstractFile addLocalDirInt(CaseDbTransaction trans, VirtualDirectory parentVd, java.io.File localFile, FileAddProgressUpdater addProgressUpdater)
synchronized LocalFile addLocalFileInt(AbstractFile parentFile, java.io.File localFile, CaseDbTransaction trans)
volatile int curNumFileSets
synchronized List< AbstractFile > openFiles(Content dataSource, String filePath)
List< AbstractFile > listFiles()
List< AbstractFile > findFiles(Content dataSource, String fileName)
List< LayoutFile > addCarvedFiles(List< CarvedFileContainer > filesToAdd)
synchronized List< AbstractFile > findFiles(Content dataSource, String fileName, String dirName)
static final Logger logger
LayoutFile addCarvedFile(String carvedFileName, long carvedFileSize, long containerId, List< TskFileRange > data)
void fireModuleContentEvent(ModuleContentEvent moduleContentEvent)
synchronized LayoutFile addCarvedFile(String carvedFileName, long carvedFileSize, long systemId, List< TskFileRange > sectors)
FileManager(SleuthkitCase tskCase)
VirtualDirectory addVirtualDirectory(long parentId, String directoryName)
static final String LOGICAL_FILE_SET_PREFIX
static Logger getLogger(String name)
static synchronized IngestServices getInstance()