Changeset 2738


Ignore:
Timestamp:
05/03/07 14:59:15 (13 years ago)
Author:
melissa
Message:

Added support for zip-compressed files.

Location:
trunk/loci/formats
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/FormatHandler.java

    r2725 r2738  
    125125      if (lname.endsWith("." + suffixes[i] + ".gz")) return true; 
    126126      //if (lname.endsWith("." + suffixes[i] + ".bz2")) return true; 
     127      if (lname.endsWith("." + suffixes[i] + ".zip")) return true; 
    127128    } 
    128129    return false; 
  • trunk/loci/formats/RandomAccessStream.java

    r2725 r2738  
    136136        dis = new DataInputStream(new GZIPInputStream(bis)); 
    137137      } 
     138      else if (path.endsWith(".zip")) { 
     139        ZipFile zf = new ZipFile(Location.getMappedId(file)); 
     140        InputStream zip =  
     141          zf.getInputStream((ZipEntry) zf.entries().nextElement()); 
     142         
     143        compressed = true; 
     144 
     145        length = 0; 
     146 
     147        while (zip.available() != 0) { 
     148          zip.read(); 
     149          length++; 
     150        } 
     151         
     152        zf = new ZipFile(Location.getMappedId(file)); 
     153        zip = new BufferedInputStream(zf.getInputStream( 
     154          (ZipEntry) zf.entries().nextElement()), MAX_OVERHEAD); 
     155        dis = new DataInputStream(zip);  
     156      } 
    138157      /* 
    139158      else if (path.endsWith(".bz2")) { 
     
    143162        length = 0; 
    144163 
    145         while (dis.available() != 0) { 
    146           length += dis.skipBytes(1024); 
     164        int s = 0; 
     165        while (s != -1) { 
     166          s = dis.read();  
     167          length++;  
    147168        } 
    148169 
     
    517538          dis = new DataInputStream(new GZIPInputStream(bis)); 
    518539        } 
     540        else if (path.endsWith(".zip")) { 
     541          //dis = new DataInputStream(new ZipInputStream(bis)); 
     542          ZipFile zf = new ZipFile(Location.getMappedId(file)); 
     543          InputStream zip = new BufferedInputStream(zf.getInputStream( 
     544            (ZipEntry) zf.entries().nextElement()), MAX_OVERHEAD); 
     545          dis = new DataInputStream(zip);  
     546        } 
    519547        /* 
    520548        else if (path.endsWith(".bz2")) { 
     
    641669        compressed = true; 
    642670      } 
     671      else if (path.endsWith(".zip")) { 
     672        ZipFile zf = new ZipFile(Location.getMappedId(file)); 
     673        InputStream zip = new BufferedInputStream(zf.getInputStream( 
     674          (ZipEntry) zf.entries().nextElement()), MAX_OVERHEAD); 
     675        dis = new DataInputStream(zip);  
     676        compressed = true; 
     677      } 
    643678      /* 
    644679      else if (path.endsWith(".bz2")) { 
Note: See TracChangeset for help on using the changeset viewer.