mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 10:17:41 +00:00
Use FileSystem class to get at the file system type
This commit is contained in:
parent
0480751945
commit
932bc3f6bf
@ -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;
|
||||
@ -250,35 +252,14 @@ 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
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Autopsy
|
||||
*
|
||||
* Copyright 2019 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> 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<String, Object> WIN32API_OPTIONS = new HashMap<String, Object>() {
|
||||
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();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user