Changeset 4691


Ignore:
Timestamp:
12/11/08 14:25:24 (11 years ago)
Author:
melissa
Message:

Prevent isThisType from throwing a NPE if the file doesn't have a parent file.

Location:
trunk/components/bio-formats/src/loci/formats/in
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/bio-formats/src/loci/formats/in/FV1000Reader.java

    r4660 r4691  
    109109    if (!open) return false; // not allowed to touch the file system 
    110110 
    111     Location parent = new Location(name).getAbsoluteFile().getParentFile(); 
    112     String path = parent.getPath(); 
    113     path = path.substring(path.lastIndexOf(File.separator) + 1); 
    114     if (path.indexOf(".") != -1) { 
    115       path = path.substring(0, path.lastIndexOf(".")); 
    116     } 
    117  
    118     Location oif = new Location(parent.getParentFile(), path); 
    119     return oif.exists() && !oif.isDirectory(); 
     111    try { 
     112      Location parent = new Location(name).getAbsoluteFile().getParentFile(); 
     113      String path = parent.getPath(); 
     114      path = path.substring(path.lastIndexOf(File.separator) + 1); 
     115      if (path.indexOf(".") != -1) { 
     116        path = path.substring(0, path.lastIndexOf(".")); 
     117      } 
     118 
     119      Location oif = new Location(parent.getParentFile(), path); 
     120      return oif.exists() && !oif.isDirectory(); 
     121    } 
     122    catch (NullPointerException e) { } 
     123    return false; 
    120124  } 
    121125 
  • trunk/components/bio-formats/src/loci/formats/in/MicromanagerReader.java

    r4684 r4691  
    8585    } 
    8686    if (!open) return false; // not allowed to touch the file system 
    87     Location parent = new Location(name).getAbsoluteFile().getParentFile(); 
    88     Location metaFile = new Location(parent, METADATA); 
    89     return metaFile.exists() && metaFile.length() > 0; 
     87    try { 
     88      Location parent = new Location(name).getAbsoluteFile().getParentFile(); 
     89      Location metaFile = new Location(parent, METADATA); 
     90      return metaFile.exists() && metaFile.length() > 0; 
     91    } 
     92    catch (NullPointerException e) { } 
     93    return false; 
    9094  } 
    9195 
Note: See TracChangeset for help on using the changeset viewer.