So I am triyng to create small java server just for file storing with methods like Save(Key, Name, Data) ang Get(Key, Name). I want to limit my server file writing permissions for storing not more than some N
gb of files totally (NOT for 1 key, but totally on server). My server is executable app, crossplatform (win, mac, lin) so I need one solution for all. Can any one point me into direction of where to get info on such topic?
views:
35answers:
1
+1
A:
If there are lots of files, scanning the files and summing their sizes is going to be pretty slow and expensive if you do it frequently. The best solution I can think of (that will go across platforms) is to scan the directory once at initialization and sum up the total sizes of the files. Then adjust the total as you write/delete files per operation. Getting the collective file sizes is easy using a File.listFiles with a custom FileFilter.
jowierun
2010-10-11 07:07:47