19 package org.sleuthkit.autopsy.modules.embeddedfileextractor;
21 import java.io.IOException;
22 import java.util.logging.Level;
23 import net.sf.sevenzipjbinding.IInStream;
24 import net.sf.sevenzipjbinding.SevenZipException;
25 import org.openide.util.NbBundle;
33 class SevenZipContentReadStream
implements IInStream {
35 private ReadContentInputStream wrapped;
38 private static final Logger logger = Logger.getLogger(SevenZipContentReadStream.class.getName());
40 public SevenZipContentReadStream(ReadContentInputStream wrapped) {
41 this.wrapped = wrapped;
42 this.length = wrapped.getLength();
46 public long seek(
long offset,
int origin)
throws SevenZipException {
47 long curPosition = wrapped.getCurPosition();
48 long newPosition = curPosition;
51 newPosition = wrapped.seek(curPosition + offset);
55 newPosition = wrapped.seek(length + offset);
58 newPosition = wrapped.seek(offset);
61 throw new IllegalArgumentException(
62 NbBundle.getMessage(
this.getClass(),
"SevenZipContentReadStream.seek.exception.invalidOrigin",
71 public int read(byte[] bytes)
throws SevenZipException {
76 if (bytes.length == 0) {
81 int readBytes = wrapped.read(bytes);
87 }
catch (IOException ex) {
89 String msg = NbBundle.getMessage(this.getClass(),
"SevenZipContentReadStream.read.exception.errReadStream");
90 logger.log(Level.WARNING, msg, ex);
91 throw new SevenZipException(msg, ex);
100 public void close() throws IOException {