This commit is contained in:
Smoss 2013-03-12 14:15:16 -04:00
commit 7624f3b040
2 changed files with 15 additions and 5 deletions

View File

@ -187,6 +187,7 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo
} else if (state.equals(State.READY)) { } else if (state.equals(State.READY)) {
ExtractMedia em = new ExtractMedia(currentFile, getJFile(currentFile)); ExtractMedia em = new ExtractMedia(currentFile, getJFile(currentFile));
em.execute(); em.execute();
em.getExtractedBytes();
} }
} }
}//GEN-LAST:event_pauseButtonActionPerformed }//GEN-LAST:event_pauseButtonActionPerformed
@ -483,14 +484,21 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo
boolean success = false; boolean success = false;
private AbstractFile sFile; private AbstractFile sFile;
private java.io.File jFile; private java.io.File jFile;
String duration; private String duration;
String position; private String position;
private long extractedBytes;
ExtractMedia(org.sleuthkit.datamodel.AbstractFile sFile, java.io.File jFile) { ExtractMedia(org.sleuthkit.datamodel.AbstractFile sFile, java.io.File jFile) {
this.sFile = sFile; this.sFile = sFile;
this.jFile = jFile; this.jFile = jFile;
} }
public long getExtractedBytes() {
return extractedBytes;
}
@Override @Override
protected Object doInBackground() throws Exception { protected Object doInBackground() throws Exception {
success = false; success = false;
@ -504,7 +512,7 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo
progress.start(); progress.start();
progress.switchToDeterminate(100); progress.switchToDeterminate(100);
try { try {
ContentUtils.writeToFile(sFile, jFile, progress, this, true); extractedBytes = ContentUtils.writeToFile(sFile, jFile, progress, this, true);
} catch (IOException ex) { } catch (IOException ex) {
logger.log(Level.WARNING, "Error buffering file", ex); logger.log(Level.WARNING, "Error buffering file", ex);
} }

View File

@ -126,7 +126,7 @@ public final class ContentUtils {
private static final int TO_FILE_BUFFER_SIZE = 8192; private static final int TO_FILE_BUFFER_SIZE = 8192;
/** /**
* Reads all the data from any content object and writes it to a file. * Reads all the data from any content object and writes (extracts) it to a file.
* *
* @param content Any content object. * @param content Any content object.
* @param outputFile Will be created if it doesn't exist, and overwritten if * @param outputFile Will be created if it doesn't exist, and overwritten if
@ -136,9 +136,10 @@ public final class ContentUtils {
* @param worker the swing worker background thread the process runs within, * @param worker the swing worker background thread the process runs within,
* or null, if in the main thread, used to handle task cancellation * or null, if in the main thread, used to handle task cancellation
* @param source true if source file * @param source true if source file
* @return number of bytes extracted
* @throws IOException if file could not be written * @throws IOException if file could not be written
*/ */
public static void writeToFile(Content content, java.io.File outputFile, public static long writeToFile(Content content, java.io.File outputFile,
ProgressHandle progress, SwingWorker worker, boolean source) throws IOException { ProgressHandle progress, SwingWorker worker, boolean source) throws IOException {
InputStream in = new ReadContentInputStream(content); InputStream in = new ReadContentInputStream(content);
@ -174,6 +175,7 @@ public final class ContentUtils {
} finally { } finally {
out.close(); out.close();
} }
return totalRead;
} }
public static void writeToFile(Content content, java.io.File outputFile) throws IOException { public static void writeToFile(Content content, java.io.File outputFile) throws IOException {