Autopsy  4.8.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
SqliteUtil.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2018-2018 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.coreutils;
20 
21 import java.io.File;
22 import java.io.IOException;
23 import java.util.List;
29 import org.sleuthkit.datamodel.AbstractFile;
30 import org.sleuthkit.datamodel.SleuthkitCase;
31 import org.sleuthkit.datamodel.TskCoreException;
32 
37 public final class SqliteUtil {
38 
39  private SqliteUtil() {
40 
41  }
42 
56  public static void findAndCopySQLiteMetaFile(AbstractFile sqliteFile)
57  throws NoCurrentCaseException, TskCoreException, IOException {
58 
59  findAndCopySQLiteMetaFile(sqliteFile, sqliteFile.getName() + "-wal");
60  findAndCopySQLiteMetaFile(sqliteFile, sqliteFile.getName() + "-shm");
61  }
62 
75  public static void findAndCopySQLiteMetaFile(AbstractFile sqliteFile,
76  String metaFileName) throws NoCurrentCaseException, TskCoreException, IOException {
77 
78  Case openCase = Case.getCurrentCaseThrows();
79  SleuthkitCase sleuthkitCase = openCase.getSleuthkitCase();
80  Services services = new Services(sleuthkitCase);
81  FileManager fileManager = services.getFileManager();
82 
83  List<AbstractFile> metaFiles = fileManager.findFiles(
84  sqliteFile.getDataSource(), metaFileName,
85  sqliteFile.getParent().getName());
86 
87  if (metaFiles != null) {
88  for (AbstractFile metaFile : metaFiles) {
90  }
91  }
92  }
93 
105  public static String writeAbstractFileToLocalDisk(AbstractFile file)
106  throws IOException, NoCurrentCaseException {
107 
108  String localDiskPath = getUniqueTempDirectoryPath(file);
109  File localDatabaseFile = new File(localDiskPath);
110  if (!localDatabaseFile.exists()) {
111  ContentUtils.writeToFile(file, localDatabaseFile);
112  }
113  return localDiskPath;
114  }
115 
126  public static String getUniqueTempDirectoryPath(AbstractFile file) throws NoCurrentCaseException {
128  + File.separator + file.getId() + file.getName();
129  }
130 }
static void findAndCopySQLiteMetaFile(AbstractFile sqliteFile)
Definition: SqliteUtil.java:56
static< T > long writeToFile(Content content, java.io.File outputFile, ProgressHandle progress, Future< T > worker, boolean source)
static void findAndCopySQLiteMetaFile(AbstractFile sqliteFile, String metaFileName)
Definition: SqliteUtil.java:75
static String writeAbstractFileToLocalDisk(AbstractFile file)
synchronized List< AbstractFile > findFiles(String fileName)
static String getUniqueTempDirectoryPath(AbstractFile file)

Copyright © 2012-2018 Basis Technology. Generated on: Thu Oct 4 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.