Changeset 3827


Ignore:
Timestamp:
03/17/08 10:56:23 (12 years ago)
Author:
melissa
Message:
  • Fixed "too many open files" bug.
  • Fixed problem with stitching files when one or more datasets in the directory have the same pattern (e.g. APC2a-e<3-5>.tif and APC2a-e<3-5>.dm3).
Location:
trunk/loci/formats
Files:
2 edited

Legend:

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

    r3794 r3827  
    892892      String[] fs = dir.list(); 
    893893 
    894       setFiles(fs, seriesBlocks[0], fp.getFirst()[0], fp.getLast()[0], 
    895         fp.getStep()[0], dpath, 0); 
     894      String ext = ""; 
     895      if (file.indexOf(".") != -1) { 
     896        ext = file.substring(file.lastIndexOf(".") + 1); 
     897      } 
     898 
     899      Vector tmpFiles = new Vector(); 
     900      for (int i=0; i<fs.length; i++) { 
     901        if (fs[i].endsWith(ext)) tmpFiles.add(fs[i]); 
     902      } 
     903 
     904      setFiles((String[]) tmpFiles.toArray(new String[0]), seriesBlocks[0], 
     905        fp.getFirst()[0], fp.getLast()[0], fp.getStep()[0], dpath, 0); 
    896906 
    897907      seriesCount = fileVector.size(); 
  • trunk/loci/formats/RandomAccessStream.java

    r3791 r3827  
    227227    afp = 0; 
    228228    length = raf.length(); 
     229    fileCache.put(this, Boolean.TRUE); 
     230    openFiles++; 
     231    if (openFiles > MAX_FILES) cleanCache(); 
    229232  } 
    230233 
     
    234237  public DataInputStream getInputStream() { 
    235238    try { 
    236       if (fileCache.get(this) == Boolean.FALSE) reopen(); 
     239      if (!((Boolean) fileCache.get(this)).booleanValue()) reopen(); 
    237240    } 
    238241    catch (IOException e) { 
     
    260263  /** Gets the number of bytes in the file. */ 
    261264  public long length() throws IOException { 
    262     if (fileCache.get(this) == Boolean.FALSE) reopen(); 
     265    if (!((Boolean) fileCache.get(this)).booleanValue()) reopen(); 
    263266    return length; 
    264267  } 
     
    274277    dis = null; 
    275278    buf = null; 
    276     if (fileCache.get(this) != Boolean.FALSE) { 
     279    if (((Boolean) fileCache.get(this)).booleanValue()) { 
    277280      fileCache.put(this, Boolean.FALSE); 
    278281      openFiles--; 
     
    501504 
    502505  public int available() throws IOException { 
    503     if (fileCache.get(this) == Boolean.FALSE) reopen(); 
     506    if (!((Boolean) fileCache.get(this)).booleanValue()) reopen(); 
    504507    int available = dis != null ? dis.available() + ext : 
    505508      (int) (length() - getFilePointer()); 
     
    510513  public void mark(int readLimit) { 
    511514    try { 
    512       if (fileCache.get(this) == Boolean.FALSE) reopen(); 
     515      if (!((Boolean) fileCache.get(this)).booleanValue()) reopen(); 
    513516    } 
    514517    catch (IOException e) { } 
     
    519522 
    520523  public void reset() throws IOException { 
    521     if (fileCache.get(this) == Boolean.FALSE) reopen(); 
     524    if (!((Boolean) fileCache.get(this)).booleanValue()) reopen(); 
    522525    dis.reset(); 
    523526    fp = length() - dis.available(); 
     
    561564   */ 
    562565  protected int checkEfficiency(int toRead) throws IOException { 
    563     if (fileCache.get(this) == Boolean.FALSE) reopen(); 
     566    if (!((Boolean) fileCache.get(this)).booleanValue()) reopen(); 
    564567    int oldBufferSize = bufferSizes[bufferSizes.length - 1]; 
    565568 
Note: See TracChangeset for help on using the changeset viewer.