/** Closes the streams. */ @Override public void close() throws IOException { if (LOGGER.isTraceEnabled()) { LOGGER.trace("RandomAccessInputStream {} CLOSE", hashCode()); } if (Location.getMappedFile(file) != null) return; if (raf != null) raf.close(); raf = null; markedPos = -1; }
private IRandomAccess getFileHandle(String flexFile) throws IOException { if (Location.getMappedFile(flexFile) != null) { return Location.getMappedFile(flexFile); } return new NIOFileHandle(new File(Location.getMappedId(flexFile)), "r", 16); }
/** Closes the streams. */ @Override public void close() throws IOException { if (LOGGER.isTraceEnabled()) { LOGGER.trace("RandomAccessInputStream {} CLOSE", hashCode()); } if (Location.getMappedFile(file) != null) return; if (raf != null) raf.close(); raf = null; markedPos = -1; }
private IRandomAccess getFileHandle(String flexFile) throws IOException { if (Location.getMappedFile(flexFile) != null) { return Location.getMappedFile(flexFile); } return new NIOFileHandle(new File(Location.getMappedId(flexFile)), "r", 16); }
/** * Returns whether or not the pathname exists. * If the pathname is a URL, then existence is determined based on whether * or not we can successfully read content from the URL. * * @return true if there is a way to read bytes from this Location's name * @see java.io.File#exists() */ public boolean exists() { if (isURL) { LOGGER.trace("exists(url)"); if (cachedProperties == null) { cachedProperties = new URLLocationProperties(this); } return cachedProperties.exists; } LOGGER.trace("exists(file)"); if (file.exists()) return true; if (getMappedFile(file.getPath()) != null) return true; String mappedId = getMappedId(file.getPath()); return mappedId != null && new File(mappedId).exists(); }
/** * Returns whether or not the pathname exists. * If the pathname is a URL, then existence is determined based on whether * or not we can successfully read content from the URL. * * @see java.io.File#exists() */ public boolean exists() { LOGGER.trace("exists()"); if (isURL) { try { url.getContent(); return true; } catch (IOException e) { LOGGER.trace("Failed to retrieve content from URL", e); return false; } } if (file.exists()) return true; if (getMappedFile(file.getPath()) != null) return true; String mappedId = getMappedId(file.getPath()); return mappedId != null && new File(mappedId).exists(); }
/** * Checks that the given id points at a valid data stream. * * @param id * The id string to validate. * @throws IOException * if the id is not valid. */ public static void checkValidId(String id) throws IOException { if (getMappedFile(id) != null) { // NB: The id maps directly to an IRandomAccess handle, so is valid. Do // not destroy an existing mapped IRandomAccess handle by closing it. return; } // NB: Try to actually open a handle to make sure it is valid. Close it // afterward so we don't leave it dangling. The process of doing this will // throw IOException if something goes wrong. Location.getHandle(id).close(); }
/** * Checks that the given id points at a valid data stream. * * @param id * The id string to validate. * @throws IOException * if the id is not valid. */ public static void checkValidId(String id) throws IOException { if (getMappedFile(id) != null) { // NB: The id maps directly to an IRandomAccess handle, so is valid. Do // not destroy an existing mapped IRandomAccess handle by closing it. return; } // NB: Try to actually open a handle to make sure it is valid. Close it // afterward so we don't leave it dangling. The process of doing this will // throw IOException if something goes wrong. Location.getHandle(id).close(); }
/** * @see loci.formats.IFormatReader#openBytes(int, byte[], int, int, int, int) */ @Override public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException { if (Location.getMappedFile(entryName) == null) { initFile(currentId); } reader.setId(entryName); return reader.openBytes(no, buf, x, y, w, h); }
private List<String> readFile(String id) throws IOException { List<String> lines = new ArrayList<String>(); long time = System.currentTimeMillis(); IRandomAccess handle = Location.getMappedFile(id); if (handle == null) {
@Override public void close(boolean fileOnly) throws IOException { super.close(fileOnly); if (reader != null) reader.close(fileOnly); if (!fileOnly) reader = null; for (String name : mappedFiles) { IRandomAccess handle = Location.getMappedFile(name); Location.mapFile(name, null); if (handle != null) { handle.close(); } } mappedFiles.clear(); entryName = null; }
/** * @see loci.formats.IFormatReader#openBytes(int, byte[], int, int, int, int) */ @Override public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException { if (Location.getMappedFile(entryName) == null) { initFile(currentId); } reader.setId(entryName); return reader.openBytes(no, buf, x, y, w, h); }
private List<String> readFile(String id) throws IOException { List<String> lines = new ArrayList<String>(); long time = System.currentTimeMillis(); IRandomAccess handle = Location.getMappedFile(id); if (handle == null) {
@Override public void close(boolean fileOnly) throws IOException { super.close(fileOnly); if (reader != null) reader.close(fileOnly); if (!fileOnly) reader = null; for (String name : mappedFiles) { IRandomAccess handle = Location.getMappedFile(name); Location.mapFile(name, null); if (handle != null) { handle.close(); } } mappedFiles.clear(); entryName = null; }
IRandomAccess handle = getMappedFile(id); if (handle == null) { LOGGER.trace("no handle was mapped for this ID");
new String[] {currentFile.getAbsolutePath()}; if (files.length == 0) { if (Location.getMappedFile(currentFile.getName()) != null) { files = new String[] {currentFile.getName()};
new String[] {currentFile.getAbsolutePath()}; if (files.length == 0) { if (Location.getMappedFile(currentFile.getName()) != null) { files = new String[] {currentFile.getName()};
IRandomAccess handle = getMappedFile(id); if (handle == null) { LOGGER.trace("no handle was mapped for this ID");
IRandomAccess ira = Location.getMappedFile(id); if (ira != null) { if (ira instanceof FileHandle) {
IRandomAccess ira = Location.getMappedFile(id); if (ira != null) { if (ira instanceof FileHandle) {