use of com.serotonin.m2m2.vo.FileStore in project ma-core-public by infiniteautomation.
the class FileStoreService method resolveFileStore.
private FileStorePath resolveFileStore(Path path) {
Path absolutePath = path.toAbsolutePath().normalize();
if (!absolutePath.startsWith(fileStoreRoot)) {
throw new TranslatableIllegalArgumentException(new TranslatableMessage("filestore.invalidPath"));
}
Path relative = fileStoreRoot.relativize(absolutePath);
if (relative.getNameCount() == 0) {
throw new TranslatableIllegalArgumentException(new TranslatableMessage("filestore.invalidPath"));
}
String fileStoreName = relative.getName(0).toString();
FileStore fileStore = getWithoutPermissionCheck(fileStoreName);
return new FileStorePath(fileStore, absolutePath);
}
use of com.serotonin.m2m2.vo.FileStore 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;
}
Aggregations