Skip to content

Commit

Permalink
Some formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Rémi Piotaix committed Nov 12, 2016
1 parent 9af597c commit 29689fe
Showing 1 changed file with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import com.amaze.filemanager.activities.MainActivity;
import com.amaze.filemanager.filesystem.RootHelper;
import com.amaze.filemanager.utils.Futils;
import com.amaze.filemanager.utils.UtilitiesProviderInterface;
import com.github.junrar.Archive;
import com.github.junrar.exception.RarException;
Expand All @@ -29,35 +28,38 @@ public class ZipExtractTask extends AsyncTask<Void, Void, Void> {
private ZipFile zipFile;
private Activity zipViewer;
private String fileName;
boolean zip;ZipEntry entry;
Archive rar;
FileHeader header;
File output;
public ZipExtractTask(UtilitiesProviderInterface utilsProvider, ZipFile zipFile, String outputDir, Activity zipViewer, String fileName,boolean zip,ZipEntry zipEntry) {
private boolean zip;
private ZipEntry entry;
private Archive rar;
private FileHeader header;
private File output;

public ZipExtractTask(UtilitiesProviderInterface utilsProvider, ZipFile zipFile, String outputDir, Activity zipViewer, String fileName, boolean zip, ZipEntry zipEntry) {
this.utilsProvider = utilsProvider;
this.zip=zip;
this.zip = zip;
this.outputDir = outputDir;
this.zipFile = zipFile;
this.zipViewer = zipViewer;
this.fileName = fileName;
this.entry=zipEntry;
this.entry = zipEntry;
}
public ZipExtractTask(UtilitiesProviderInterface utilsProvider, Archive rar, String outputDir, Activity zipViewer, String fileName,boolean zip,FileHeader fileHeader) {

public ZipExtractTask(UtilitiesProviderInterface utilsProvider, Archive rar, String outputDir, Activity zipViewer, String fileName, boolean zip, FileHeader fileHeader) {
this.utilsProvider = utilsProvider;
this.zip=zip;
this.zip = zip;
this.outputDir = outputDir;
this.rar = rar;
this.zipViewer = zipViewer;
this.fileName = fileName;
this.header = fileHeader;
}

@Override
protected Void doInBackground(Void... zipEntries) {

try {
if (zip) unzipEntry1(zipFile, entry, outputDir);
else unzipRAREntry(rar,header,outputDir);
}catch (Exception e) {
else unzipRAREntry(rar, header, outputDir);
} catch (Exception e) {
e.printStackTrace();
}
return null;
Expand All @@ -71,9 +73,9 @@ protected void onPostExecute(Void aVoid) {
Log.d("change permissions", cmd);
RootHelper.runAndWait(cmd, false);
utilsProvider.getFutils().openFile(output, (MainActivity) zipViewer);
}
private void unzipEntry1(ZipFile zipfile, ZipEntry entry, String outputDir)
}

private void unzipEntry1(ZipFile zipfile, ZipEntry entry, String outputDir)
throws IOException {

output = new File(outputDir, fileName);
Expand All @@ -85,19 +87,17 @@ private void unzipEntry1(ZipFile zipfile, ZipEntry entry, String outputDir)
int len;
byte buf[] = new byte[1024];
while ((len = inputStream.read(buf)) > 0) {

outputStream.write(buf, 0, len);
}
} finally {
outputStream.close();
inputStream.close();
}
}

private void unzipRAREntry(Archive zipfile, FileHeader header, String outputDir)
throws IOException, RarException {

output = new File(outputDir + "/" + header.getFileNameString().trim());
private void unzipRAREntry(Archive zipfile, FileHeader header, String outputDir)
throws IOException, RarException {
output = new File(outputDir + "/" + header.getFileNameString().trim());
FileOutputStream fileOutputStream = new FileOutputStream(output);
zipfile.extractFile(header, fileOutputStream);
}
Expand Down

0 comments on commit 29689fe

Please sign in to comment.