public String lengthDesc() { if (file.isFile()) { return VrUtils.formatFileSize(file.length()); } if (file.isDirectory()) { VFile[] files = file.listFiles(); int f = 0; int d = 0; if (files != null) { for (VFile ff : files) { if (ff.isDirectory()) { d++; } else { f++; } } } if (f == 0 && d == 0) { return "vide"; } StringBuilder sb = new StringBuilder(); if (d > 0) { sb.append(d).append(" rep."); } if (f > 0) { if (sb.length() > 0) { sb.append(", "); } sb.append(f).append(" fich."); } return sb.toString(); } return ""; }
public long length() { if (file.isFile()) { return file.length(); } if (file.isDirectory()) { VFile[] files = file.listFiles(); return files == null ? 0 : files.length; } return 0; }