diff --git a/Core/src/org/sleuthkit/autopsy/logicalimager/configuration/ConfigVisualPanel1.java b/Core/src/org/sleuthkit/autopsy/logicalimager/configuration/ConfigVisualPanel1.java index 042906c0b3..fc683be97a 100644 --- a/Core/src/org/sleuthkit/autopsy/logicalimager/configuration/ConfigVisualPanel1.java +++ b/Core/src/org/sleuthkit/autopsy/logicalimager/configuration/ConfigVisualPanel1.java @@ -22,8 +22,6 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonIOException; import com.google.gson.JsonSyntaxException; -import com.sun.jna.platform.win32.WinDef.DWORD; -import com.sun.jna.ptr.IntByReference; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -31,7 +29,11 @@ import java.io.IOException; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import java.nio.file.FileStore; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; import java.nio.file.Files; +import java.nio.file.Paths; +import java.nio.file.spi.FileSystemProvider; import java.util.ArrayList; import java.util.List; import java.util.logging.Level; @@ -249,36 +251,15 @@ final class ConfigVisualPanel1 extends JPanel { * */ @Messages({"ConfigVisualPanel1.unknown=Unknown"}) - private String getFileSystemName(String drive){ - char[] lpVolumeNameBuffer = new char[256]; - DWORD nVolumeNameSize = new DWORD(256); - IntByReference lpVolumeSerialNumber = new IntByReference(); - IntByReference lpMaximumComponentLength = new IntByReference(); - IntByReference lpFileSystemFlags = new IntByReference(); - - char[] lpFileSystemNameBuffer = new char[256]; - DWORD nFileSystemNameSize = new DWORD(256); - - lpVolumeSerialNumber.setValue(0); - lpMaximumComponentLength.setValue(256); - lpFileSystemFlags.setValue(0); - - Kernel32.INSTANCE.GetVolumeInformation( - drive, - lpVolumeNameBuffer, - nVolumeNameSize, - lpVolumeSerialNumber, - lpMaximumComponentLength, - lpFileSystemFlags, - lpFileSystemNameBuffer, - nFileSystemNameSize); - if (Kernel32.INSTANCE.GetLastError() != 0) { - logger.log(Level.INFO, String.format("Last error: %d", Kernel32.INSTANCE.GetLastError())); // NON-NLS + private String getFileSystemName(String drive) { + FileSystem fileSystem = FileSystems.getDefault(); + FileSystemProvider provider = fileSystem.provider(); + try { + FileStore fileStore = provider.getFileStore(Paths.get(drive)); + return fileStore.type(); + } catch (IOException ex) { return Bundle.ConfigVisualPanel1_unknown(); } - - String fs = new String(lpFileSystemNameBuffer); - return fs.trim(); } /** diff --git a/Core/src/org/sleuthkit/autopsy/logicalimager/configuration/Kernel32.java b/Core/src/org/sleuthkit/autopsy/logicalimager/configuration/Kernel32.java deleted file mode 100644 index 59f62e9909..0000000000 --- a/Core/src/org/sleuthkit/autopsy/logicalimager/configuration/Kernel32.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Autopsy - * - * Copyright 2019 Basis Technology Corp. - * Contact: carrier sleuthkit org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.sleuthkit.autopsy.logicalimager.configuration; - -import com.sun.jna.Library; -import com.sun.jna.Native; -import com.sun.jna.platform.win32.WinDef.DWORD; -import com.sun.jna.ptr.IntByReference; -import com.sun.jna.win32.StdCallLibrary; -import com.sun.jna.win32.W32APIFunctionMapper; -import com.sun.jna.win32.W32APITypeMapper; -import java.util.HashMap; -import java.util.Map; - -/** - * Windows Kernel32 interface - */ -public interface Kernel32 extends StdCallLibrary { - - static Map WIN32API_OPTIONS = new HashMap() { - private static final long serialVersionUID = 1L; - { - put(Library.OPTION_FUNCTION_MAPPER, W32APIFunctionMapper.UNICODE); - put(Library.OPTION_TYPE_MAPPER, W32APITypeMapper.UNICODE); - } - }; - - Kernel32 INSTANCE = (Kernel32) Native.loadLibrary("Kernel32", Kernel32.class, WIN32API_OPTIONS); - - /* - BOOL WINAPI GetVolumeInformation( - __in_opt LPCTSTR lpRootPathName, - __out LPTSTR lpVolumeNameBuffer, - __in DWORD nVolumeNameSize, - __out_opt LPDWORD lpVolumeSerialNumber, - __out_opt LPDWORD lpMaximumComponentLength, - __out_opt LPDWORD lpFileSystemFlags, - __out LPTSTR lpFileSystemNameBuffer, - __in DWORD nFileSystemNameSize - ); - */ - boolean GetVolumeInformation( - String lpRootPathName, - char[] lpVolumeNameBuffer, - DWORD nVolumeNameSize, - IntByReference lpVolumeSerialNumber, - IntByReference lpMaximumComponentLength, - IntByReference lpFileSystemFlags, - char[] lpFileSystemNameBuffer, - DWORD nFileSystemNameSize - ); - - int GetLastError(); -}