Subversion Repositories XServices

Compare Revisions

Ignore whitespace Rev 176 → Rev 177

/xservices/trunk/src/java/net/brutex/xservices/ws/rs/FileInfoImpl.java
73,12 → 73,14
*/
public Response getFiles(HttpHeaders h, UriInfo uriInfo, String dir, boolean withDir, boolean withFiles, int level, String search, int count, int page, boolean useCache)
{
if(dir==null) {
dir = "c:/";
logger.warn("No directory specified. Default is 'c:/'.");
}
isPermitted(dir);
URI baseuri = URI.create(uriInfo.getBaseUri()+FileInfo.BASE_PATH+"getFile?file=");
if(dir==null) {dir = "c:/"; System.out.println("No directory specified.");}
logger.info(String.format("Listing directory '%s'.", dir));
if (level <= 0) level = 1;
 
109,9 → 111,8
logger.info(String.format("Returning items %s to %s from total of %s items in the list.", fromIndex, toIndex, list.size()));
return Response.ok(sublist).build();
} catch (CacheException e) {
Response.serverError().build();
return Response.serverError().build();
}
return null;
}
 
/**
254,4 → 255,14
}
return true;
}
 
//http://stackoverflow.com/questions/3758606/how-to-convert-byte-size-into-human-readable-format-in-java
private static String humanReadableByteCount(long bytes, boolean si) {
int unit = si ? 1000 : 1024;
if (bytes < unit) return bytes + " B";
int exp = (int) (Math.log(bytes) / Math.log(unit));
String pre = (si ? "kMGTPE" : "KMGTPE").charAt(exp-1) + (si ? "" : "i");
return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre);
}
 
}