final int cleandir()
{
   if(localdir==null) return 0;
   if(objects.size()!=0) return 0; /* safe-check */

   int rc;
   rc=1;

   File thisdir=new File(localdir.substring(0,localdir.length()-1));
//   System.out.println("/debug/ Cleandir: STARTING for "+localdir);
   localdir=null;
   String filez[]=thisdir.list();
   if(filez==null) return 1;

   /* delete any files found there */
   for(int i=0;i<filez.length;i++)
   {
  //   System.out.println("/debug/ Cleandir: Trying to delete "+filez[i]);
     if(! ( (new File(thisdir,filez[i])).delete()) ) 
     {
	 rc=0;
     }
   }

   if(rc==0)
   {
     return 0;
   }

   rc=0;

   /* likvidujeme up-dirs*/
   while(thisdir.delete())
   {
     rc++;
//     System.out.println("/debug/ Cleandir: Deleted dir "+thisdir+" rc="+rc);
     String par;
     par=thisdir.getParent();
     if(par==null) break;
     thisdir=new File(par);
   }

   return rc;
}