protected void init(String filePath, boolean write) throws IOException, FormatException { if (!write || readerFile.exists()) { if (write) { log.debug("Initialized in a write-context; setting read-only for " + filePath); } if (!readerFile.exists() && !readerFile.canRead()) { throw new IOException("Cannot access " + filePath); } initializeReader(); } else { final File readerDir = readerFile.getParentFile(); writerFile = File.createTempFile("." + readerFile.getName(), ".tmp", readerDir); writerFile.deleteOnExit(); acquireLock(); } }
private BfPixelBuffer delegate() { if (isWrite()) { try { closeWriter(); try { initializeReader(); } catch (FormatException e) { throw new RuntimeException(e); } } catch (IOException e1) { throw new RuntimeException(e1); } } else if (delegate == null) { try { initializeReader(); } catch (IOException e) { throw new RuntimeException(e); } catch (FormatException e) { throw new RuntimeException(e); } } return delegate; }