Skip to content

Commit

Permalink
Remove throws clause
Browse files Browse the repository at this point in the history
  • Loading branch information
torusrxxx committed Dec 1, 2024
1 parent 3292cbc commit f8eb2ef
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/freenet/support/io/Fallocate.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,21 @@ public static Fallocate forChannel(FileChannel channel, FileDescriptor fd, long
return new Fallocate(channel, getDescriptor(fd), final_filesize);
}

public Fallocate fromOffset(long offset) throws IllegalArgumentException {
/**
* @throws IllegalArgumentException
*/
public Fallocate fromOffset(long offset) {
if(offset < 0 || offset > final_filesize) throw new IllegalArgumentException();
this.offset = offset;
return this;
}

// This method only works for Linux, do not use it.
/**
* This method only works for Linux, do not use it.
* @throws UnsupportedOperationException
*/
@Deprecated
public Fallocate keepSize() throws UnsupportedOperationException {
public Fallocate keepSize() {
if (!IS_LINUX) {
throw new UnsupportedOperationException("fallocate keep size is not supported on this file system");
}
Expand All @@ -64,7 +70,7 @@ public Fallocate keepSize() throws UnsupportedOperationException {
public void execute() throws IOException {
int errno = 0;
boolean isUnsupported = false;
if (fd != 0) {
if (fd > 2) {
if (IS_LINUX) {
final int result = FallocateHolder.fallocate(fd, mode, offset, final_filesize-offset);
errno = result == 0 ? 0 : Native.getLastError();
Expand Down

0 comments on commit f8eb2ef

Please sign in to comment.