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);
76 if (files.isEmpty()) {
77 return Collections.emptyList();
81 for (Iterator<String> iterator = files.iterator(); iterator.hasNext();) {
82 String file = iterator.next();
89 List<String> extentFiles =
new ArrayList<>();
90 for (String fileName : files) {
91 File file = imageFolderPath.resolve(fileName).toFile();
98 files.removeAll(extentFiles);
114 List<String> extentFiles =
new ArrayList<>();
117 try (BufferedReader br =
new BufferedReader(
new FileReader(file))) {
118 String line = br.readLine();
119 while (null != line) {
129 String[] splited = line.split(
" ");
130 if (splited.length < MIN_VMDK_EXTENT_DESCRIPTOR_FIELDS) {
134 if (splited[0].equals(
"RW") || splited[0].equals(
"RDONLY") || splited[0].equals(
"NOACCESS")) {
140 extentFiles.add(extentFileName);
142 line = br.readLine();
144 }
catch (Exception ex) {
145 logger.log(Level.WARNING, String.format(
"Error while parsing vmdk descriptor file %s", file.toString()), ex);
152 for (FileFilter filter : filters) {
153 if (filter.accept(file)) {
170 File file =
new File(path);
171 String[] files = file.list((File current, String name) ->
new File(current, name).isFile());
174 return Collections.emptyList();
176 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)