Has anyone got any clever tricks for determining the size of the contents of a directory without doing the obvious (descend recursively and count bytes)?
I'm trying to make a progress bar happen for a recursive descend-read-and-load of a directory, and it would be cool if I could track it by bytes read, but doing two descents of the same directory seems a little wrong to me. ("Yo, dawg, I heard you like recursive descent, so I put a recursive descent on your recursive descent so you can recursively descend before you recursively descend" :) )
I've got something that works, based on subdividing the amount to complete and passing that percentage to the next recursion, but obviously that tends to stick a little when I get five levels down and the percentage assigned to each file gets miniscule. Updating the progress bar by bytes would avoid that problem and make the progress look smoother, if I could get the total byte count of the directory. Unfortunately, File.length() is undefined for directories - any other brilliant ideas?
EDIT: re-reading this, I see that the thread title is not very accurate. Oh, well
Edited by jon.kiparsky: n/a