@Override public String[] getSeriesUsedFiles(boolean noPixels) { if (noPixels) { return parameterFile == null ? null : new String[] {parameterFile}; } String id = new Location(currentId).getAbsolutePath(); return parameterFile == null ? new String[] {id} : new String[] {id, parameterFile}; }
/** * Returns the canonical path to this file. * If the file is a URL, then the canonical path is equivalent to the * absolute file ({@link #getAbsoluteFile()}). Otherwise, this method * will delegate to {@link java.io.File#getCanonicalFile()}. * * @return see above * @throws IOException if the canonical path cannot be constructed * @see java.io.File#getCanonicalFile() */ public Location getCanonicalFile() throws IOException { return isURL ? getAbsoluteFile() : new Location(file.getCanonicalFile()); }
private static Location findXML(String name) { Location parent = new Location(name).getAbsoluteFile().getParentFile(); Location xml = new Location(parent, XML_FILE); if (xml.exists()) { return xml; } if (parent.getParent() != null) { xml = new Location(parent.getParentFile(), XML_FILE); if (xml.exists()) { return xml; } } return null; }
@Override public void endElement(String uri, String localName, String qName) { String value = currentValue.toString(); if (qName.equals("bts:MeasurementRecord") && btsType.equals("IMG") && value.trim().length() > 0) { Location imgFile = new Location(parentDir, value); if (imgFile.exists()) { planes.get(planes.size() - 1).file = imgFile.getAbsolutePath(); } } }
/** * Return a list of absolute files in this directory. Hidden files will * be included in the list. * If this is not a directory, return null. */ public Location[] listFiles() { String[] s = list(); if (s == null) return null; Location[] f = new Location[s.length]; for (int i=0; i<f.length; i++) { f[i] = new Location(getAbsolutePath(), s[i]); f[i] = f[i].getAbsoluteFile(); } return f; }
/** * Translate a file path from the XML file to an actual path on disk. * The path stored in the XML file may not have the same case as the path on * disk (typically all lower case on disk and possibly mixed case in XML). * If a matching file cannot be found, then the path from the XML file is returned. * * Uses {@link #directoryCache} so that any given directory is only listed once * per initialization, not once per lookup. */ private String lookup(String src) { Location f = new Location(src); String parent = f.getParent(); String name = f.getName(); String[] list = directoryCache.get(parent); if (list == null) { list = f.getParentFile().list(); Arrays.sort(list); directoryCache.put(parent, list); } for (String s : list) { if (s.equalsIgnoreCase(name)) { return new Location(f.getParentFile(), s).getAbsolutePath(); } } return src; }
/** Finds the first file with one of the given suffixes. */ private Location find(final String[] suffix) { final Location file = new Location(currentId).getAbsoluteFile(); final Location parent = file.getParentFile(); final String[] listing = parent.list(); for (final String name : listing) { if (checkSuffix(name, suffix)) { return new Location(parent, name); } } return null; }
@Override public boolean isThisType(String name, boolean open) { Location file = new Location(name).getAbsoluteFile(); return file.getName().equals("fid") || file.getName().equals("acqp"); }
@Override protected void initFile(String id) throws FormatException, IOException { TIFFInfo info = evalFile(id); if (new Location(info.origname).getAbsoluteFile().exists()) { super.initFile(info.origname); } else { super.initFile(id); } this.tiffInfo = info; super.initFileMain(info.origname); }
@Override public String[] getSeriesUsedFiles(boolean noPixels) { FormatTools.assertId(currentId, true, 1); String dir = pixelsFiles.get(getSeries()); Location realDir = new Location(dir).getParentFile(); realDir = realDir.getParentFile(); realDir = realDir.getParentFile(); dir = realDir.getAbsolutePath(); ArrayList<String> files = new ArrayList<String>(); files.add(new Location(getCurrentFile()).getAbsolutePath()); for (String f : allFiles) { if (f.startsWith(dir) && (!f.endsWith("2dseq") || !noPixels)) { if (!files.contains(f)) { files.add(f); } } } return files.toArray(new String[files.size()]); }
@Override public boolean isSingleFile(String id) throws FormatException, IOException { if (checkSuffix(id, "xml")) return false; Location file = new Location(id); String[] list = file.getParentFile().list(); for (String f : list) { if (checkSuffix(f, "xml") && DataTools.samePrefix(file.getName(), f)) { return false; } } return true; }
private static Location findXML(String name) { Location parent = new Location(name).getAbsoluteFile().getParentFile(); Location xml = new Location(parent, XML_FILE); if (xml.exists()) { return xml; } if (parent.getParent() != null) { xml = new Location(parent.getParentFile(), XML_FILE); if (xml.exists()) { return xml; } } return null; }
@Override public String[] getSeriesUsedFiles(boolean noPixels) { if (noPixels) { return parameterFile == null ? null : new String[] {parameterFile}; } String id = new Location(currentId).getAbsolutePath(); return parameterFile == null ? new String[] {id} : new String[] {id, parameterFile}; }
@Override public void endElement(String uri, String localName, String qName) { String value = currentValue.toString(); if (qName.equals("bts:MeasurementRecord") && btsType.equals("IMG") && value.trim().length() > 0) { Location imgFile = new Location(parentDir, value); if (imgFile.exists()) { planes.get(planes.size() - 1).file = imgFile.getAbsolutePath(); } } }
@Override public boolean isThisType(String name, boolean open) { if (checkSuffix(name, "xys")) return true; // verify that there is an .xys file in the same directory if (name.indexOf(' ') == -1) return false; if (!open) return false; String prefix = name.substring(0, name.lastIndexOf(" ")); Location xys = new Location(prefix + " 1.xys"); return xys.exists(); }
/** * Return a list of files in this directory, or null if this file is * not a directory. * * @return a list of absolute files in this directory. Hidden files will * be included in the list. If this is not a directory, return null. * @see #list() */ public Location[] listFiles() { String[] s = list(); if (s == null) return null; Location[] f = new Location[s.length]; for (int i=0; i<f.length; i++) { f[i] = new Location(getAbsolutePath(), s[i]); f[i] = f[i].getAbsoluteFile(); } return f; }
/** Finds the first file with one of the given suffixes. */ private Location find(final String[] suffix) { final Location file = new Location(currentId).getAbsoluteFile(); final Location parent = file.getParentFile(); final String[] listing = parent.list(); for (final String name : listing) { if (checkSuffix(name, suffix)) { return new Location(parent, name); } } return null; }