Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Directory lengths  RSS feed

 
Steve Sinai
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi - does anyone know if there's a way to very quickly get the size of a directory? I am writing a Windows's-like filechooser popup that lists the sizes of files and directories. For directories, I am using a recursive function that adds up the sizes of the files and subdirectories. But sometimes this doesn't work fast enough, and my program starts to hang. I'm hoping there's some obscure Java extension call that I don't know about. Or is there some Windows shell function I can call directly though to? Thanks.
 
Vlado Zajac
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no quick way to get the size (disk usage) of whole directory with all subdirectories. It is needed to read all subdirectories (recursively) from disk (at least those which are not in cache) which is slow for bigger directory tree.

Using an OS function may seed id up, but the disk accesses are still required.
[ December 20, 2005: Message edited by: Vlado Zajac ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!