Changeset 3842


Ignore:
Timestamp:
03/21/08 14:56:06 (12 years ago)
Author:
melissa
Message:

Fixed a bunch of file mapping problems.

Location:
trunk/loci/formats/in
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/in/InCellReader.java

    r3794 r3842  
    191191      if (qName.equals("Image")) { 
    192192        String file = attributes.getValue("filename"); 
    193         Location parent = 
    194           new Location(currentId).getAbsoluteFile().getParentFile(); 
    195         tiffs.add(new Location(parent, file).getAbsolutePath()); 
     193        Location current = new Location(currentId).getAbsoluteFile(); 
     194        if (new Location(current.getParentFile(), file).exists()) { 
     195          tiffs.add( 
     196            new Location(current.getParentFile(), file).getAbsolutePath()); 
     197        } 
     198        else tiffs.add(file); 
    196199      } 
    197200      else if (qName.equals("Identifier")) { 
  • trunk/loci/formats/in/LeicaReader.java

    r3829 r3842  
    264264      super.initFile(id); 
    265265 
    266       leiFilename = new Location(id).getAbsolutePath(); 
     266      leiFilename = new File(id).exists() ? 
     267        new Location(id).getAbsolutePath() : id; 
    267268      in = new RandomAccessStream(id); 
    268269 
     
    342343          listing = dirFile.getParentFile().list(); 
    343344          dirPrefix = dirFile.getParent(); 
     345          if (!dirPrefix.endsWith(File.separator)) dirPrefix += File.separator; 
    344346        } 
    345347        else { 
     
    365367          prefix = DataTools.stripString(new String(tempData, 
    366368            20 + j*nameLength, nameLength)); 
    367           f.add(dirPrefix + File.separator + prefix); 
     369          f.add(dirPrefix + prefix); 
    368370          // test to make sure the path is valid 
    369371          Location test = new Location((String) f.get(f.size() - 1)); 
  • trunk/loci/formats/in/MicromanagerReader.java

    r3794 r3842  
    6666  /* @see loci.formats.IFormatReader#isThisType(String, boolean) */ 
    6767  public boolean isThisType(String name, boolean open) { 
     68    if (name.endsWith(METADATA)) return true; 
    6869    if (!open) return false; // not allowed to touch the file system 
    6970    Location parent = new Location(name).getAbsoluteFile().getParentFile(); 
     
    135136      METADATA).getAbsolutePath() : METADATA; 
    136137    in = new RandomAccessStream(metadataFile); 
    137     String parent = file.exists() ? file.getParentFile().getAbsolutePath() : ""; 
     138    String parent = file.exists() ? 
     139      file.getParentFile().getAbsolutePath() + File.separator : ""; 
    138140 
    139141    // usually a small file, so we can afford to read it into memory 
     
    153155      if (pos == -1 || pos >= in.length()) break; 
    154156      String name = s.substring(s.indexOf(":", pos), s.indexOf(",", pos)); 
    155       tiffs.add(0, 
    156         parent + File.separator + name.substring(3, name.length() - 1)); 
     157      tiffs.add(0, parent + name.substring(3, name.length() - 1)); 
    157158      pos++; 
    158159    } 
  • trunk/loci/formats/in/OMETiffReader.java

    r3804 r3842  
    122122    // look for additional files in the dataset 
    123123    Vector files = new Vector(); 
    124     Location l = new Location(currentId); 
    125     l = l.getAbsoluteFile().getParentFile(); 
    126     String[] fileList = l.list(); 
     124    Location l = new Location(currentId).getAbsoluteFile().getParentFile(); 
     125    String[] fileList = new File(currentId).exists() ? l.list() : 
     126      (String[]) Location.getIdMap().keySet().toArray(new String[0]); 
    127127 
    128128    /* 
  • trunk/loci/formats/in/PerkinElmerReader.java

    r3781 r3842  
    221221 
    222222    // get the working directory 
    223     Location tempFile = new Location(id).getAbsoluteFile(); 
    224     Location workingDir = tempFile.getParentFile(); 
    225     if (workingDir == null) workingDir = new Location("."); 
    226     String workingDirPath = workingDir.getPath() + File.separator; 
     223    File tmpFile = new File(id).getAbsoluteFile(); 
     224    File workingDir = tmpFile.getParentFile(); 
     225    if (workingDir == null) workingDir = new File("."); 
     226    String workingDirPath = workingDir.getPath(); 
     227    if (!workingDirPath.equals("")) workingDirPath += File.separator; 
    227228    String[] ls = workingDir.list(); 
     229    if (!new File(id).exists()) { 
     230      ls = (String[]) Location.getIdMap().keySet().toArray(new String[0]); 
     231      workingDirPath = ""; 
     232    } 
    228233 
    229234    float pixelSizeX = 1f, pixelSizeY = 1f; 
     
    245250    files = new String[ls.length]; 
    246251 
    247     String tempFileName = tempFile.getName(); 
    248     int dot = tempFileName.lastIndexOf("."); 
    249     String check = dot < 0 ? tempFileName : tempFileName.substring(0, dot); 
     252    int dot = id.lastIndexOf("."); 
     253    String check = dot < 0 ? id : id.substring(0, dot); 
     254    check = check.substring(check.lastIndexOf(File.separator) + 1); 
    250255 
    251256    // locate appropriate .tim, .csv, .zpo, .htm and .tif files 
    252257 
    253258    String prefix = null; 
     259 
     260    Location tempFile = null; 
    254261 
    255262    for (int i=0; i<ls.length; i++) { 
     
    262269        d = ls[i].lastIndexOf("."); 
    263270      } 
    264       String s = dot < 0 ? ls[i] : ls[i].substring(0, d); 
     271      String s = d < 0 ? ls[i] : ls[i].substring(0, d); 
    265272 
    266273      if (s.startsWith(check) || check.startsWith(s) || 
     
    381388 
    382389    if (cfgPos != -1) { 
    383       tempFile = new Location(workingDir, ls[cfgPos]); 
    384       allFiles.add(tempFile.getAbsolutePath()); 
     390      tempFile = new Location(workingDirPath, ls[cfgPos]); 
     391      if (!workingDirPath.equals("")) allFiles.add(tempFile.getAbsolutePath()); 
     392      else allFiles.add(ls[cfgPos]); 
    385393    } 
    386394    if (anoPos != -1) { 
    387       tempFile = new Location(workingDir, ls[anoPos]); 
    388       allFiles.add(tempFile.getAbsolutePath()); 
     395      tempFile = new Location(workingDirPath, ls[anoPos]); 
     396      if (!workingDirPath.equals("")) allFiles.add(tempFile.getAbsolutePath()); 
     397      else allFiles.add(ls[anoPos]); 
    389398    } 
    390399    if (recPos != -1) { 
    391       tempFile = new Location(workingDir, ls[recPos]); 
    392       allFiles.add(tempFile.getAbsolutePath()); 
     400      tempFile = new Location(workingDirPath, ls[recPos]); 
     401      if (!workingDirPath.equals("")) allFiles.add(tempFile.getAbsolutePath()); 
     402      else allFiles.add(ls[recPos]); 
    393403    } 
    394404 
    395405    if (timPos != -1) { 
    396       tempFile = new Location(workingDir, ls[timPos]); 
    397       allFiles.add(tempFile.getAbsolutePath()); 
    398       read = new RandomAccessStream(tempFile.getAbsolutePath()); 
    399       data = new byte[(int) tempFile.length()]; 
    400       read.read(data); 
    401       t = new StringTokenizer(new String(data)); 
     406      tempFile = new Location(workingDirPath, ls[timPos]); 
     407      if (!workingDirPath.equals("")) allFiles.add(tempFile.getAbsolutePath()); 
     408      else allFiles.add(ls[timPos]); 
     409      read = new RandomAccessStream((String) allFiles.get(allFiles.size() - 1)); 
     410      t = new StringTokenizer(read.readString((int) read.length())); 
    402411      int tNum = 0; 
    403412      // can ignore "Zero x" and "Extra int" 
     
    465474 
    466475    if (csvPos != -1) { 
    467       tempFile = new Location(workingDir, ls[csvPos]); 
    468       allFiles.add(tempFile.getAbsolutePath()); 
    469       read = new RandomAccessStream(tempFile.getAbsolutePath()); 
    470       data = new byte[(int) tempFile.length()]; 
    471       read.read(data); 
    472       t = new StringTokenizer(new String(data)); 
     476      tempFile = new Location(workingDirPath, ls[csvPos]); 
     477      if (!workingDirPath.equals("")) allFiles.add(tempFile.getAbsolutePath()); 
     478      else allFiles.add(ls[csvPos]); 
     479      read = new RandomAccessStream((String) allFiles.get(allFiles.size() - 1)); 
     480      t = new StringTokenizer(read.readString((int) read.length())); 
    473481      int tNum = 0; 
    474482      String[] hashKeys = {"Calibration Unit", "Pixel Size X", "Pixel Size Y", 
     
    547555    } 
    548556    if (zpoPos != -1) { 
    549       tempFile = new Location(workingDir, ls[zpoPos]); 
    550       allFiles.add(tempFile.getAbsolutePath()); 
     557      tempFile = new Location(workingDirPath, ls[zpoPos]); 
     558      if (!workingDirPath.equals("")) allFiles.add(tempFile.getAbsolutePath()); 
     559      else allFiles.add(ls[zpoPos]); 
    551560      if (csvPos < 0) { 
    552561        // parse .zpo only if no .csv is available 
    553         read = new RandomAccessStream(tempFile.getAbsolutePath()); 
    554         data = new byte[(int) tempFile.length()]; 
    555         read.read(data); 
    556         t = new StringTokenizer(new String(data)); 
     562        read = 
     563          new RandomAccessStream((String) allFiles.get(allFiles.size() - 1)); 
     564        t = new StringTokenizer(read.readString((int) read.length())); 
    557565        int tNum = 0; 
    558566        while (t.hasMoreTokens()) { 
     
    573581 
    574582    if (htmPos != -1) { 
    575       tempFile = new Location(workingDir, ls[htmPos]); 
    576       allFiles.add(tempFile.getAbsolutePath()); 
    577       read = new RandomAccessStream(tempFile.getAbsolutePath()); 
    578       data = new byte[(int) tempFile.length()]; 
     583      tempFile = new Location(workingDirPath, ls[htmPos]); 
     584      if (!workingDirPath.equals("")) allFiles.add(tempFile.getAbsolutePath()); 
     585      else allFiles.add(ls[htmPos]); 
     586      read = new RandomAccessStream((String) allFiles.get(allFiles.size() - 1)); 
     587      data = new byte[(int) read.length()]; 
    579588      read.read(data); 
    580589 
  • trunk/loci/formats/in/PrairieReader.java

    r3781 r3842  
    8888 
    8989    if (checkSuffix(name, CFG_SUFFIX)) { 
     90      if (prefix.lastIndexOf("Config") == -1) return false; 
    9091      prefix = prefix.substring(0, prefix.lastIndexOf("Config")); 
    9192    } 
  • trunk/loci/formats/in/QTReader.java

    r3792 r3842  
    136136        b = new byte[(int) len]; 
    137137        in.readFully(b); 
     138        in.close(); 
    138139      } 
    139140      catch (IOException exc) { 
     
    388389      if (f.exists()) { 
    389390        if (debug) debug("\t Found: " + f); 
     391        if (in != null) in.close(); 
    390392        in = new RandomAccessStream(f.getAbsolutePath()); 
    391393 
     
    401403        if (f.exists()) { 
    402404          if (debug) debug("\t Found: " + f); 
     405          if (in != null) in.close(); 
    403406          in = new RandomAccessStream(f.getAbsolutePath()); 
    404407          stripHeader(); 
     
    411414          if (f.exists()) { 
    412415            if (debug) debug("\t Found: " + f); 
     416            if (in != null) in.close(); 
    413417            in = new RandomAccessStream(f.getAbsolutePath()); 
    414418            stripHeader(); 
     
    425429      } 
    426430    } 
    427  
    428     in = new RandomAccessStream(currentId); 
    429431 
    430432    core.rgb[0] = bitsPerPixel < 40; 
  • trunk/loci/formats/in/VisitechReader.java

    r3794 r3842  
    128128    // first, make sure we have the HTML file 
    129129 
    130     if (checkSuffix(id, HTML_SUFFIX)) { 
    131       Location file = new Location(id).getAbsoluteFile(); 
    132       String path = file.exists() ? file.getPath() : id; 
    133       int ndx = path.lastIndexOf(File.separator); 
    134       String base = path.substring(ndx + 1, path.lastIndexOf(" ")); 
     130    if (!checkSuffix(id, HTML_SUFFIX)) { 
     131      String base = id.substring(0, id.lastIndexOf(" ")); 
    135132 
    136133      String suffix = " Report.html"; 
    137134      currentId = null; 
    138       initFile(file.exists() ? new Location(file.getParent(), 
    139         base + suffix).getAbsolutePath() : base + suffix); 
     135      initFile(base + suffix); 
    140136      return; 
    141137    } 
Note: See TracChangeset for help on using the changeset viewer.