Search in sources :

Example 1 with DiskInfo

use of com.serotonin.m2m2.module.definitions.settings.DiskInfoDefinition.DiskInfo in project ma-core-public by infiniteautomation.

the class DiskInfoDefinition method getValue.

@Override
public List<DiskInfo> getValue() {
    FileSystem fs = FileSystems.getDefault();
    List<DiskInfo> disks = new ArrayList<DiskInfo>();
    for (Path root : fs.getRootDirectories()) {
        try {
            FileStore store = Files.getFileStore(root);
            DiskInfo disk = new DiskInfo();
            disk.setName(root.getRoot().toString());
            disk.setTotalSpace(store.getTotalSpace());
            disk.setUsableSpace(store.getUsableSpace());
            disks.add(disk);
        } catch (IOException e) {
        }
    }
    return disks;
}
Also used : Path(java.nio.file.Path) FileStore(java.nio.file.FileStore) FileSystem(java.nio.file.FileSystem) ArrayList(java.util.ArrayList) DiskInfo(com.serotonin.m2m2.module.definitions.settings.DiskInfoDefinition.DiskInfo) IOException(java.io.IOException)

Example 2 with DiskInfo

use of com.serotonin.m2m2.module.definitions.settings.DiskInfoDefinition.DiskInfo in project ma-core-public by MangoAutomation.

the class DiskInfoDefinition method getValue.

@Override
public List<DiskInfo> getValue() {
    FileSystem fs = FileSystems.getDefault();
    List<DiskInfo> disks = new ArrayList<DiskInfo>();
    for (Path root : fs.getRootDirectories()) {
        try {
            FileStore store = Files.getFileStore(root);
            DiskInfo disk = new DiskInfo();
            disk.setName(root.getRoot().toString());
            disk.setTotalSpace(store.getTotalSpace());
            disk.setUsableSpace(store.getUsableSpace());
            disks.add(disk);
        } catch (IOException e) {
        }
    }
    return disks;
}
Also used : Path(java.nio.file.Path) FileStore(java.nio.file.FileStore) FileSystem(java.nio.file.FileSystem) ArrayList(java.util.ArrayList) DiskInfo(com.serotonin.m2m2.module.definitions.settings.DiskInfoDefinition.DiskInfo) IOException(java.io.IOException)

Aggregations

DiskInfo (com.serotonin.m2m2.module.definitions.settings.DiskInfoDefinition.DiskInfo)2 IOException (java.io.IOException)2 FileStore (java.nio.file.FileStore)2 FileSystem (java.nio.file.FileSystem)2 Path (java.nio.file.Path)2 ArrayList (java.util.ArrayList)2