Search in sources :

Example 16 with TarEntry

use of org.apache.tools.tar.TarEntry in project gradle by gradle.

the class TarTaskOutputPacker method storeMissingProperty.

private void storeMissingProperty(String propertyPath, TarOutputStream outputStream) throws IOException {
    TarEntry entry = new TarEntry("missing-" + propertyPath);
    outputStream.putNextEntry(entry);
    outputStream.closeEntry();
}
Also used : TarEntry(org.apache.tools.tar.TarEntry)

Example 17 with TarEntry

use of org.apache.tools.tar.TarEntry in project OpenRefine by OpenRefine.

the class ImportingUtilities method explodeArchive.

public static boolean explodeArchive(File rawDataDir, InputStream archiveIS, JSONObject archiveFileRecord, JSONArray fileRecords, final Progress progress) {
    if (archiveIS instanceof TarInputStream) {
        TarInputStream tis = (TarInputStream) archiveIS;
        try {
            TarEntry te;
            while (!progress.isCanceled() && (te = tis.getNextEntry()) != null) {
                if (!te.isDirectory()) {
                    String fileName2 = te.getName();
                    File file2 = allocateFile(rawDataDir, fileName2);
                    progress.setProgress("Extracting " + fileName2, -1);
                    JSONObject fileRecord2 = new JSONObject();
                    JSONUtilities.safePut(fileRecord2, "origin", JSONUtilities.getString(archiveFileRecord, "origin", null));
                    JSONUtilities.safePut(fileRecord2, "declaredEncoding", (String) null);
                    JSONUtilities.safePut(fileRecord2, "declaredMimeType", (String) null);
                    JSONUtilities.safePut(fileRecord2, "fileName", fileName2);
                    JSONUtilities.safePut(fileRecord2, "archiveFileName", JSONUtilities.getString(archiveFileRecord, "fileName", null));
                    JSONUtilities.safePut(fileRecord2, "location", getRelativePath(file2, rawDataDir));
                    JSONUtilities.safePut(fileRecord2, "size", saveStreamToFile(tis, file2, null));
                    postProcessSingleRetrievedFile(file2, fileRecord2);
                    JSONUtilities.append(fileRecords, fileRecord2);
                }
            }
        } catch (IOException e) {
            // TODO: what to do?
            e.printStackTrace();
        }
        return true;
    } else if (archiveIS instanceof ZipInputStream) {
        ZipInputStream zis = (ZipInputStream) archiveIS;
        try {
            ZipEntry ze;
            while (!progress.isCanceled() && (ze = zis.getNextEntry()) != null) {
                if (!ze.isDirectory()) {
                    String fileName2 = ze.getName();
                    File file2 = allocateFile(rawDataDir, fileName2);
                    progress.setProgress("Extracting " + fileName2, -1);
                    JSONObject fileRecord2 = new JSONObject();
                    JSONUtilities.safePut(fileRecord2, "origin", JSONUtilities.getString(archiveFileRecord, "origin", null));
                    JSONUtilities.safePut(fileRecord2, "declaredEncoding", (String) null);
                    JSONUtilities.safePut(fileRecord2, "declaredMimeType", (String) null);
                    JSONUtilities.safePut(fileRecord2, "fileName", fileName2);
                    JSONUtilities.safePut(fileRecord2, "archiveFileName", JSONUtilities.getString(archiveFileRecord, "fileName", null));
                    JSONUtilities.safePut(fileRecord2, "location", getRelativePath(file2, rawDataDir));
                    JSONUtilities.safePut(fileRecord2, "size", saveStreamToFile(zis, file2, null));
                    postProcessSingleRetrievedFile(file2, fileRecord2);
                    JSONUtilities.append(fileRecords, fileRecord2);
                }
            }
        } catch (IOException e) {
            // TODO: what to do?
            e.printStackTrace();
        }
        return true;
    }
    return false;
}
Also used : ZipInputStream(java.util.zip.ZipInputStream) JSONObject(org.json.JSONObject) TarInputStream(org.apache.tools.tar.TarInputStream) ZipEntry(java.util.zip.ZipEntry) TarEntry(org.apache.tools.tar.TarEntry) IOException(java.io.IOException) File(java.io.File)

Example 18 with TarEntry

use of org.apache.tools.tar.TarEntry in project gradle by gradle.

the class AntTarPacker method pack.

@Override
public void pack(List<DataSource> inputs, DataTarget output) throws IOException {
    TarOutputStream tarOutput = new TarOutputStream(output.openOutput());
    for (DataSource input : inputs) {
        TarEntry entry = new TarEntry(input.getName());
        entry.setSize(input.getLength());
        tarOutput.putNextEntry(entry);
        PackerUtils.packEntry(input, tarOutput, buffer);
        tarOutput.closeEntry();
    }
    tarOutput.close();
}
Also used : TarOutputStream(org.apache.tools.tar.TarOutputStream) TarEntry(org.apache.tools.tar.TarEntry)

Aggregations

TarEntry (org.apache.tools.tar.TarEntry)18 File (java.io.File)6 IOException (java.io.IOException)4 TarInputStream (org.apache.tools.tar.TarInputStream)4 IOException2 (hudson.util.IOException2)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 FileOutputStream (java.io.FileOutputStream)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 TarOutputStream (org.apache.tools.tar.TarOutputStream)2 TarInputStream (hudson.org.apache.tools.tar.TarInputStream)1 FileInputStream (java.io.FileInputStream)1 OutputStream (java.io.OutputStream)1 ArrayList (java.util.ArrayList)1 JarFile (java.util.jar.JarFile)1 Matcher (java.util.regex.Matcher)1 ZipEntry (java.util.zip.ZipEntry)1 ZipInputStream (java.util.zip.ZipInputStream)1 ZipOutputStream (java.util.zip.ZipOutputStream)1 CloseShieldInputStream (org.apache.commons.io.input.CloseShieldInputStream)1 TextField (org.apache.lucene.document.TextField)1