/** * Returns the total number of (compressed) bytes this stream has written * to the underlying stream. */ public long length() { return this.dos.size(); }
private static int prefixLength(String p) { return Paths.prefixLength(p, SEPARATOR_CHAR, true); }
throw new InputException("an input exception has occurred");
private void assertSplit(final String path) { final File file = new File(path); final String parent = file.getParent(); final String member = file.getName(); final Splitter splitter = Paths.split(path, File.separatorChar, false); assertEquals(parent, splitter.getParentPath()); assertEquals(member, splitter.getMemberName()); }
@Test public void testChainingExceptionWithInitializedPredecessor() { builder.warn(newCause()); builder.warn(newCause()); try { builder.check(); fail(); } catch (final SequentialIOException expected) { assert expected.isInitPredecessor(); builder.warn(newCause()); builder.warn(expected); builder.warn(newCause()); } }
/** * Removes any redundant {@code "."}, {@code ".."} directories from the * path name. * * @return The normalized path string denoting the same file or * directory as this instance. */ public String getNormalizedPath() { return Paths.normalize(getPath(), separatorChar); }
@Test public void testIdentity() throws X { assertSequence(new Identity()); }
@Test public void testAppearance() throws X { assertSequence(new Appearance()); }
@Test public void testPriority() throws X { assertSequence(new Priority()); }
private void assertChain( final Check c, final SequentialIOException[] expected, SequentialIOException exc) { assert c != null; for (int i = 0; i < expected.length; i++) { final SequentialIOException exp = expected[i]; assertNotNull(exp); assertNotNull(exc); assertTrue(c.equals(exp, exc)); exc = exc.getPredecessor(); } assertNull(exc); }
@Override public void write(int b) throws IOException { checkAllExceptions(); delegate.write(b); }
@Override public SeekableByteChannel position(long newPosition) throws IOException { checkAllExceptions(); delegate.position(newPosition); return this; }
@Override @SuppressWarnings("deprecation") protected synchronized InputStream getInputStream( String name, Boolean check, boolean process) throws IOException { final InputStream in = super.getInputStream(name, check, process); return in == null ? null : new de.schlichtherle.truezip.io.SynchronizedInputStream(in, this); }
@Override public boolean markSupported() { checkUndeclaredExceptions(); return delegate.markSupported(); } }
@Override public void write(byte[] b, int off, int len) throws IOException { checkAllExceptions(); delegate.write(b, off, len); }
@Override public int write(ByteBuffer src) throws IOException { checkAllExceptions(); return delegate.write(src); }
@Override public void close() throws IOException { checkAllExceptions(); delegate.close(); } }
@Override public SeekableByteChannel truncate(long size) throws IOException { checkAllExceptions(); delegate.truncate(size); return this; }