1
Fork 0
mirror of https://github.com/Steffo99/unimore-oop-2020-cleaver.git synced 2024-11-22 16:14:18 +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 --> <!-- NewPage -->
<html lang="it"> <html lang="it">
<head> <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> <title>ChpFileError</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <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="description" content="declaration: module: eu.steffo.cleaver, package: eu.steffo.cleaver.errors, class: ChpFileError">
<meta name="generator" content="javadoc/ClassWriterImpl"> <meta name="generator" content="javadoc/ClassWriterImpl">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style"> <link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">

View file

@ -2,10 +2,10 @@
<!-- NewPage --> <!-- NewPage -->
<html lang="it"> <html lang="it">
<head> <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> <title>ProgrammingError</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <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="description" content="declaration: module: eu.steffo.cleaver, package: eu.steffo.cleaver.errors, class: ProgrammingError">
<meta name="generator" content="javadoc/ClassWriterImpl"> <meta name="generator" content="javadoc/ClassWriterImpl">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style"> <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> </thead>
<tbody> <tbody>
<tr class="altColor"> <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> <td class="colLast">&nbsp;</td>
</tr> </tr>
</tbody> </tbody>
@ -168,8 +168,8 @@ extends <a href="https://docs.oracle.com/en/java/javase/13/docs/api/java.base/ja
<ul class="blockList"> <ul class="blockList">
<li class="blockList"> <li class="blockList">
<section class="detail"> <section class="detail">
<h3><a id="&lt;init&gt;()">ProgrammingError</a></h3> <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>()</div> <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> </section>
</li> </li>
</ul> </ul>

View file

@ -2,10 +2,10 @@
<!-- NewPage --> <!-- NewPage -->
<html lang="it"> <html lang="it">
<head> <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> <title>eu.steffo.cleaver.errors</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <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="description" content="declaration: module: eu.steffo.cleaver, package: eu.steffo.cleaver.errors">
<meta name="generator" content="javadoc/PackageWriterImpl"> <meta name="generator" content="javadoc/PackageWriterImpl">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style"> <link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">

View file

@ -2,10 +2,10 @@
<!-- NewPage --> <!-- NewPage -->
<html lang="it"> <html lang="it">
<head> <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> <title>eu.steffo.cleaver.errors Class Hierarchy</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <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="description" content="tree: module: eu.steffo.cleaver, package: eu.steffo.cleaver.errors">
<meta name="generator" content="javadoc/PackageTreeWriter"> <meta name="generator" content="javadoc/PackageTreeWriter">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style"> <link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">

View file

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