Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/jdiskmark/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public enum Mode { CLI, GUI }
public static String os;
public static String arch;
public static String processorName;
public static String motherBoardName;
public static String jdk;
// elevated priviledges
public static boolean isRoot = false;
Expand Down Expand Up @@ -167,6 +168,7 @@ public static void init() {
os = System.getProperty("os.name");
arch = System.getProperty("os.arch");
processorName = Util.getProcessorName();
motherBoardName=Util.getMotherBoardName();
jdk = Util.getJvmInfo();

checkPermission();
Expand Down Expand Up @@ -576,6 +578,7 @@ static public String getDriveInfo() {
if (locationDir == null) {
return LOCATION_NOT_SELECTED_ERROR;
}
String interFaceType=Util.getInterfaceType();
String driveModel = Util.getDriveModel(locationDir);
String partitionId = Util.getPartitionId(locationDir.toPath());
DiskUsageInfo usageInfo;
Expand All @@ -585,7 +588,7 @@ static public String getDriveInfo() {
usageInfo = new DiskUsageInfo();
Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
}
return driveModel + " - " + partitionId + ": " + usageInfo.getUsageTitleDisplay();
return interFaceType + " - " + driveModel + " - " + partitionId + ": " + usageInfo.getUsageTitleDisplay();
}

static public String getDriveModel() {
Expand Down
4 changes: 4 additions & 0 deletions src/jdiskmark/MainFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ public MainFrame() {
if (App.processorName != null && !App.processorName.isEmpty()) {
titleSb.append(" - ").append(App.processorName);
}

if (App.motherBoardName != null && !App.motherBoardName.isEmpty()) {
titleSb.append(" | ").append(App.motherBoardName);
}

// permission indicator
if (App.isAdmin) titleSb.append(" [Admin]");
Expand Down
89 changes: 88 additions & 1 deletion src/jdiskmark/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.filechooser.FileSystemView;

/**
Expand Down Expand Up @@ -49,7 +51,7 @@ static public boolean deleteDirectory(File path) {
* @param min Minimum value
* @param max Maximum value. Must be greater than min.
* @return Integer between min and max, inclusive.
* @see java.util.Random#nextInt(int)
* @see Random#nextInt(int)
*/
public static int randInt(int min, int max) {

Expand Down Expand Up @@ -273,4 +275,89 @@ public static String getProcessorName() {
}
return "processor name unknown";
}

public static String getMotherBoardName() {

Process process = null;

try {
if (App.os.startsWith("Windows")) {
process = new ProcessBuilder("wmic", "baseboard", "get", "Product").start();
} else if (App.os.contains("Linux")) {
process = new ProcessBuilder("cat", "/sys/devices/virtual/dmi/id/board_name").start();
} else if (App.os.startsWith("Mac OS")) {
process = new ProcessBuilder("system_profiler", "SPHardwareDataType").start();
}
} catch (IOException e) {
Logger.getLogger(Util.class.getName())
.log(Level.FINE, "Unable to get Motherboard Name", e);
return null;
}

// If no command was set (unsupported OS)
if (process == null) { return null; }

try (BufferedReader reader =
new BufferedReader(new InputStreamReader(process.getInputStream()))) {

StringBuilder builder = new StringBuilder();
String line;

while ((line = reader.readLine()) != null) {
builder.append(line).append(" ");
}

return builder.toString().trim();

} catch (IOException e) {
Logger.getLogger(Util.class.getName())
.log(Level.FINE, "Unable to read Motherboard Name", e);
return null;
}
}

public static String getInterfaceType(){
Process process = null;

try {
if (App.os.startsWith("Windows")) {
process = new ProcessBuilder("wmic", "diskdrive", "get", "InterfaceType").start();
} else if (App.os.contains("Linux")) {
process = new ProcessBuilder("lsblk", "-d", "-o", "tran").start();
} else if (App.os.startsWith("Mac OS")) {
process = new ProcessBuilder("diskutil", "info", "disk0").start();
}
} catch (IOException e) {
Logger.getLogger(Util.class.getName())
.log(Level.FINE, "Unable to get Interface Type", e);
return "OS not supported";
}

if (process == null) { return "OS not supported"; }

try (BufferedReader reader =
new BufferedReader(new InputStreamReader(process.getInputStream()))) {

String line;

while ((line = reader.readLine()) != null) {

line=line.trim();

if(line.isEmpty()) { continue;}

if(line.equalsIgnoreCase("InterfaceType") || line.equalsIgnoreCase("TRAN")|| line.equalsIgnoreCase("NAME")) { continue;}

return line;
}

} catch (IOException e) {
Logger.getLogger(Util.class.getName())
.log(Level.FINE, "Unable to read Interface Type", e);
return "OS not supported";
}

return "OS not supported";
}

}