OSHI:获取给定路径的HWDiskStore [英] OSHI: Get HWDiskStore for a given path

查看:682
本文介绍了OSHI:获取给定路径的HWDiskStore的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用OSHI https://github.com/oshi/oshi 来监视硬件

I am using OSHI https://github.com/oshi/oshi to monitor the hardware.

有一种方法

HWDiskStore[] getDisks();

https://github.com/oshi/oshi/blob/master/oshi-core/src/main/java /oshi/hardware/Disks.java
来获取计算机上所有硬盘的列表。

https://github.com/oshi/oshi/blob/master/oshi-core/src/main/java/oshi/hardware/Disks.java to get the list of all hard drives on the machine.

是否有可能获得 HWDiskStore 用于特定路径,例如

Is it possible to get HWDiskStore for a particular path like

FileStore getFileStore(Path path)

https://docs.oracle.com/javase/8/docs/api/java/nio/file /Files.html#getFileStore-java.nio.file.Path-

如果没有,匹配 HWDiskStore 具有给定路径,例如使用磁盘名称或序列号等?

If no, what is a reliable way to match a HWDiskStore with a given path, e.g. use disk name or serial number, etc.?

推荐答案

DiskStore是硬件对象(例如,硬盘,SSD等) 。)是机器的一部分,而FileStore是与操作系统/文件系统关联的软件对象。

The DiskStore is a hardware object (e.g., hard drive, SSD, etc.) which is part of the machinery, while the FileStore is a software object associated with the Operating System / File System.

OSHI的 HWDiskStore 对象具有 getPartitions( ) 方法,该方法返回 HWPartition 对象的数组。这些对象具有 getMountPoint( ) 方法,该方法应该是与 OSFileStore 挂载点相对应的 String

OSHI's HWDiskStore objects have a getPartitions() method, which returns an array of HWPartition objects. These objects have a getMountPoint() method which should be a String corresponding to the OSFileStore mount point.

OSHI的 OSFileStore 对象与Java FileStore 对象相对应,并具有一个 getMount() 方法,该方法应直接匹配 HWPartition 挂载点。

OSHI's OSFileStore objects correspond to the Java FileStore objects and have a getMount() method which should directly match the HWPartition mount point.

演示类给出了一个示例如何关联这些信息。

This demo class gives an example of how this information can be correlated.

这篇关于OSHI:获取给定路径的HWDiskStore的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆