Skip to content

Commit 05a0d2b

Browse files
committed
DataHandle: add a mutator for the length
In SCIFIO and Bio-Formats, this was a feature of the AbstractNIOHandle. But there is no reason to limit it to NIO-flavored handles only.
1 parent c134f4a commit 05a0d2b

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/main/java/org/scijava/io/handle/DataHandle.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ public interface DataHandle<L extends Location> extends WrapperPlugin<L>,
6666
/** Returns the length of the stream. */
6767
long length() throws IOException;
6868

69+
/**
70+
* Sets the new length of the handle.
71+
*
72+
* @param length New length.
73+
* @throws IOException If there is an error changing the handle's length.
74+
*/
75+
void setLength(long length) throws IOException;
76+
6977
/**
7078
* Returns the current order of the stream.
7179
*

src/main/java/org/scijava/io/handle/FileHandle.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ public long length() throws IOException {
8383
return raf().length();
8484
}
8585

86+
@Override
87+
public void setLength(final long length) throws IOException {
88+
raf().setLength(length);
89+
}
90+
8691
@Override
8792
public int read() throws IOException {
8893
return raf().read();

0 commit comments

Comments
 (0)