home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Java / Java.zip / jload18.zip / minicachedir.java < prev    next >
Text File  |  2000-04-24  |  2KB  |  89 lines

  1. /*
  2.  *  Smart Cache , http proxy caching server
  3.  *  Copyright (C) 1998 Radim Kolar <hsn@cybermail.net>
  4.  *
  5.  *  This program is free software; you can redistribute it and/or modify
  6.  *  it under the terms of the GNU General Public License as published by
  7.  *  the Free Software Foundation; either version 2, or (at your option)
  8.  *  any later version.
  9.  *
  10.  *  This program is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  *  GNU General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU General Public License
  16.  *  along with this program; if not, write to the Free Software
  17.  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  */
  20.  
  21. import java.io.*;
  22. import java.util.*;
  23. import java.util.zip.*;
  24. import java.net.*;
  25.  
  26. public final class minicachedir extends localdir{
  27.  
  28. public static final String DIRINFO=".cacheinfo";
  29.  
  30. minicachedir(String locdir)
  31. {
  32.  super(locdir);
  33. }
  34.  
  35. protected final void localinit()
  36. {
  37.  File f=new File(name);
  38.  if(!f.exists() || !f.isDirectory())
  39.   {
  40.    return;
  41.   }
  42.  /* nacteme cachovane objekty */
  43.  
  44.  DataInputStream is=null;
  45.  try{
  46.  is=new DataInputStream( 
  47.                  new BufferedInputStream(
  48.                  new FileInputStream( name+DIRINFO ),4096));
  49.                  
  50.  int howmany=is.readInt();
  51.  for(int i=0;i<howmany;i++)
  52.   {
  53.    localurl lu;
  54.    String name,ctype,localname,location;
  55.    long date;
  56.  
  57.    name=is.readUTF();
  58.    ctype=is.readUTF();
  59.    localname=is.readUTF();
  60.    location=is.readUTF();
  61.    if(location.length()==0) location=null;
  62.    is.readInt();
  63.    is.readInt();
  64.    is.readLong();
  65.    date=is.readLong();
  66.    is.readLong();
  67.    is.readLong(); 
  68.  
  69.    if(localname.equals("<>")) continue;
  70.    
  71.    lu=new localurl(this.name,name,localname,ctype,location,date);
  72.    objects.put(name,lu);
  73.   }
  74.  is.close(); 
  75.  }
  76.  catch(IOException e) {
  77.                        try{
  78.                          if(is!=null) { System.out.println("I/O error reading "+name+DIRINFO+" ,file corrupted?");
  79.                                         is.close();
  80.                                       }
  81.                           }
  82.                         catch (IOException z) {}  
  83.                        };
  84. } /* konstruktor */
  85.  
  86.  
  87.  
  88. } /* class */
  89.