Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

20
LINES

< > BotCompany Repo | #1023142 // diskSpacePercentage_oshi - return % full of partition (including inodes)

JavaX fragment (include)

static double diskSpacePercentage_oshi() {
  ret diskSpacePercentage_oshi(userDir()); // default to home partition
}

static double diskSpacePercentage_oshi(File f) {
  OSFileStore fs = oshi_findFileStore(f);
  if (fs == null) { // default to non-oshi
    long total = f.getTotalSpace();
    long usable = f.getUsableSpace();
    ret doubleRatio(total-usable, total);
  }
  
  long total = fs.getTotalSpace();
  long usable = fs.getUsableSpace();
  long total2 = fs.getTotalInodes();
  long usable2 = fs.getFreeInodes();
  
  ret max(doubleRatio(total-usable, total),
    total2 <= 0 ? 0 : doubleRatio(total2-usable2, total2))*100;
}

Author comment

Began life as a copy of #1014297

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, nazvggbglmsf, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1023142
Snippet name: diskSpacePercentage_oshi - return % full of partition (including inodes)
Eternal ID of this version: #1023142/5
Text MD5: 5d5950a00b020742a860deb220e77b61
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-05-15 15:32:41
Source code size: 652 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 197 / 244
Version history: 4 change(s)
Referenced in: [show references]