19 package org.sleuthkit.autopsy.modules.vmextractor;
21 import java.io.BufferedReader;
23 import java.io.FileReader;
24 import java.nio.file.Path;
25 import java.util.ArrayList;
26 import java.util.Arrays;
27 import java.util.Collections;
28 import java.util.Iterator;
29 import java.util.List;
30 import java.util.logging.Level;
31 import javax.swing.filechooser.FileFilter;
47 private static final List<FileFilter>
vmFiltersList =
new ArrayList<>();
50 vmFiltersList.add(virtualMachineFilter);
53 private static final List<String>
VMDK_EXTS = Arrays.asList(
new String[]{
".vmdk"});
58 vmdkFiltersList.add(vmdkFilter);
80 if (files.isEmpty()) {
81 return Collections.emptyList();
85 for (Iterator<String> iterator = files.iterator(); iterator.hasNext();) {
86 String file = iterator.next();
93 List<String> extentFiles =
new ArrayList<>();
94 for (String fileName : files) {
95 File file = imageFolderPath.resolve(fileName).toFile();
102 files.removeAll(extentFiles);
118 List<String> extentFiles =
new ArrayList<>();
121 try (BufferedReader br =
new BufferedReader(
new FileReader(file))) {
123 while ((line = br.readLine()) != null) {
133 String[] splited = line.split(
" ");
134 if (splited.length < MIN_VMDK_EXTENT_DESCRIPTOR_FIELDS_NUM) {
138 if (splited[0].equals(
"RW") || splited[0].equals(
"RDONLY") || splited[0].equals(
"NOACCESS")) {
144 extentFiles.add(extentFileName);
147 }
catch (Exception ex) {
148 logger.log(Level.WARNING, String.format(
"Error while parsing vmdk descriptor file %s", file.toString()), ex);
173 String fName = fileName.toLowerCase();
174 int lastPeriod = fName.lastIndexOf(
'.');
175 if (-1 == lastPeriod) {
178 String fNameNoExt = fName.substring(0, lastPeriod);
179 return fNameNoExt.matches(
".*-[fs]\\d+$");
184 for (FileFilter filter : filters) {
185 if (filter.accept(file)) {
202 File file =
new File(path);
203 String[] files = file.list((File current, String name) ->
new File(current, name).isFile());
206 return Collections.emptyList();
208 return new ArrayList<>(Arrays.asList(files));
static final String VIRTUAL_MACHINE_DESC
static final List< String > VIRTUAL_MACHINE_EXTS
synchronized static Logger getLogger(String name)