Support fskip for better decompress perf

* Actually the whole impl can't be more sucks, will import algorithm to manage buffer and read strategy further
This commit is contained in:
tarsin committed 2022-05-23 17:34:59 +08:00
1 parent 64d91eed33
commit 863337c789
3 files changed
+33 -1

No files matched your search

@@ -72,6 +72,26 @@ public class UriArchiveAccessor implements Closeable {
Os.lseek(fd, 0, OsConstants.SEEK_SET);
}
public long skip(long n) throws IOException, ErrnoException {
long pos;
long len;
long newpos;
if (n <= 0) {
return 0;
}
pos = Os.lseek(fd, 0L, OsConstants.SEEK_CUR);
len = length();
newpos = pos + n;
if (newpos > len) {
newpos = len;
}
seek(newpos, OsConstants.SEEK_SET);
/* return the actual number of bytes skipped */
return newpos - pos;
}
public void close() throws IOException {
pfd.close();
try {