1
Fork 0
mirror of https://github.com/Steffo99/unimore-oop-2020-cleaver.git synced 2024-11-22 08:04:19 +00:00

Incomplete: use buffered reads and writes

This commit is contained in:
Steffo 2020-01-09 00:35:50 +01:00
parent fb94fd27ed
commit 606b1b3b2f
5 changed files with 18 additions and 22 deletions

View file

@ -2,10 +2,10 @@
<!-- NewPage -->
<html lang="it">
<head>
<!-- Generated by javadoc (13.0.1) on Sun Jan 05 18:44:04 CET 2020 -->
<!-- Generated by javadoc (13.0.1) on Thu Jan 09 00:14:43 CET 2020 -->
<title>ChpFileError</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="dc.created" content="2020-01-05">
<meta name="dc.created" content="2020-01-09">
<meta name="description" content="declaration: module: eu.steffo.cleaver, package: eu.steffo.cleaver.errors, class: ChpFileError">
<meta name="generator" content="javadoc/ClassWriterImpl">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">

View file

@ -2,10 +2,10 @@
<!-- NewPage -->
<html lang="it">
<head>
<!-- Generated by javadoc (13.0.1) on Sun Jan 05 18:44:04 CET 2020 -->
<!-- Generated by javadoc (13.0.1) on Thu Jan 09 00:14:43 CET 2020 -->
<title>ProgrammingError</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="dc.created" content="2020-01-05">
<meta name="dc.created" content="2020-01-09">
<meta name="description" content="declaration: module: eu.steffo.cleaver, package: eu.steffo.cleaver.errors, class: ProgrammingError">
<meta name="generator" content="javadoc/ClassWriterImpl">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
@ -129,7 +129,7 @@ extends <a href="https://docs.oracle.com/en/java/javase/13/docs/api/java.base/ja
</thead>
<tbody>
<tr class="altColor">
<th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="#%3Cinit%3E()">ProgrammingError</a></span>()</code></th>
<th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="#%3Cinit%3E(java.lang.String)">ProgrammingError</a></span>&#8203;(<a href="https://docs.oracle.com/en/java/javase/13/docs/api/java.base/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a>&nbsp;s)</code></th>
<td class="colLast">&nbsp;</td>
</tr>
</tbody>
@ -168,8 +168,8 @@ extends <a href="https://docs.oracle.com/en/java/javase/13/docs/api/java.base/ja
<ul class="blockList">
<li class="blockList">
<section class="detail">
<h3><a id="&lt;init&gt;()">ProgrammingError</a></h3>
<div class="memberSignature"><span class="modifiers">public</span>&nbsp;<span class="memberName">ProgrammingError</span>()</div>
<h3><a id="&lt;init&gt;(java.lang.String)">ProgrammingError</a></h3>
<div class="memberSignature"><span class="modifiers">public</span>&nbsp;<span class="memberName">ProgrammingError</span>&#8203;(<span class="arguments"><a href="https://docs.oracle.com/en/java/javase/13/docs/api/java.base/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a>&nbsp;s)</span></div>
</section>
</li>
</ul>

View file

@ -2,10 +2,10 @@
<!-- NewPage -->
<html lang="it">
<head>
<!-- Generated by javadoc (13.0.1) on Sun Jan 05 18:44:04 CET 2020 -->
<!-- Generated by javadoc (13.0.1) on Thu Jan 09 00:14:43 CET 2020 -->
<title>eu.steffo.cleaver.errors</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="dc.created" content="2020-01-05">
<meta name="dc.created" content="2020-01-09">
<meta name="description" content="declaration: module: eu.steffo.cleaver, package: eu.steffo.cleaver.errors">
<meta name="generator" content="javadoc/PackageWriterImpl">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">

View file

@ -2,10 +2,10 @@
<!-- NewPage -->
<html lang="it">
<head>
<!-- Generated by javadoc (13.0.1) on Sun Jan 05 18:44:04 CET 2020 -->
<!-- Generated by javadoc (13.0.1) on Thu Jan 09 00:14:43 CET 2020 -->
<title>eu.steffo.cleaver.errors Class Hierarchy</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="dc.created" content="2020-01-05">
<meta name="dc.created" content="2020-01-09">
<meta name="description" content="tree: module: eu.steffo.cleaver, package: eu.steffo.cleaver.errors">
<meta name="generator" content="javadoc/PackageTreeWriter">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">

View file

@ -149,7 +149,7 @@ public class StitchJob extends Job {
return doc;
}
private static final int UPDATE_EVERY_BYTES = 16000;
private static final int BUFFER_SIZE = 16384;
@Override
public void run() {
@ -161,18 +161,14 @@ public class StitchJob extends Job {
InputStream inputStream = ICleaverInputStream.fromElement(cleaverNode, chpFolder, cryptKey);
OutputStream outputStream = new FileOutputStream(resultFile);
//Pipe everything to the output
int bytesUntilNextUpdate = UPDATE_EVERY_BYTES;
//Pipe everything to the output, in chunks
this.setProgress(new WorkingProgress());
int i;
while((i = inputStream.read()) != -1) {
outputStream.write(i);
bytesUntilNextUpdate -= 1;
if(bytesUntilNextUpdate <= 0) {
byte[] buffer = new byte[BUFFER_SIZE];
//Loop until the first byte in the buffer is -1
while(inputStream.read(buffer) != -1) {
outputStream.write(buffer);
this.setProgress(new WorkingProgress((float)(resultFile.length() - inputStream.available()) / (float)resultFile.length()));
bytesUntilNextUpdate = UPDATE_EVERY_BYTES;
}
}
inputStream.close();