convenience bindings for {bytes} {megabytes} and {gigabytes}

This commit is contained in:
Reinhard Pointner 2015-12-25 12:39:58 +00:00
parent b13efb9c14
commit b4108ed2a5
1 changed files with 15 additions and 0 deletions

View File

@ -788,6 +788,21 @@ public class MediaBindingBean {
return getMediaFile().getParentFile(); return getMediaFile().getParentFile();
} }
@Define("bytes")
public Long getFileSize() {
return getInferredMediaFile().length();
}
@Define("megabytes")
public String getFileSizeInMegaBytes() {
return String.format("%.0f", getFileSize() / Math.pow(1000, 2));
}
@Define("gigabytes")
public String getFileSizeInGigaBytes() {
return String.format("%.1f", getFileSize() / Math.pow(1000, 3));
}
@Define("home") @Define("home")
public File getUserHome() throws IOException { public File getUserHome() throws IOException {
return Settings.getRealUserHome(); return Settings.getRealUserHome();