Examples of SevenZArchiveEntry


Examples of org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry

        final File file2 = getFile("test2.xml");

        final SevenZOutputFile outArchive = new SevenZOutputFile(output);
        outArchive.setContentCompression(method);
        try {
            SevenZArchiveEntry entry;
           
            entry = outArchive.createArchiveEntry(file1, file1.getName());
            outArchive.putArchiveEntry(entry);
            copy(file1, outArchive);
            outArchive.closeArchiveEntry();
           
            entry = outArchive.createArchiveEntry(file2, file2.getName());
            outArchive.putArchiveEntry(entry);
            copy(file2, outArchive);
            outArchive.closeArchiveEntry();
        } finally {
            outArchive.close();
        }
       
        final SevenZFile archive = new SevenZFile(output);
        try {
            SevenZArchiveEntry entry;
           
            entry = archive.getNextEntry();
            assert(entry != null);
            assertEquals(entry.getName(), file1.getName());
           
            entry = archive.getNextEntry();
            assert(entry != null);
            assertEquals(entry.getName(), file2.getName());
           
            assert(archive.getNextEntry() == null);
        } finally {
            archive.close();
        }
View Full Code Here

Examples of org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry

                log.info("auto-detected archive format: 7Z");

                final SevenZFile sevenZFile = new SevenZFile(archive);

                try {
                    SevenZArchiveEntry entry;
                    while( (entry = sevenZFile.getNextEntry()) != null) {

                        if(! entry.isDirectory()) {
                            log.info("loading entry {} ...", entry.getName());

                            // detect the file format
                            RDFFormat detectedFormat = Rio.getParserFormatForFileName(entry.getName());
                            if(format == null) {
                                if(detectedFormat != null) {
                                    log.info("auto-detected entry format: {}", detectedFormat.getName());
                                    format = detectedFormat;
                                } else {
                                    throw new RDFParseException("could not detect input format of entry "+ entry.getName());
                                }
                            } else {
                                if(detectedFormat != null && !format.equals(detectedFormat)) {
                                    log.warn("user-specified entry format ({}) overrides auto-detected format ({})", format.getName(), detectedFormat.getName());
                                } else {
                                    log.info("user-specified entry format: {}", format.getName());
                                }
                            }


                            load(new InputStream() {
                                @Override
                                public int read() throws IOException {
                                    return sevenZFile.read();
                                }

                                @Override
                                public int read(byte[] b) throws IOException {
                                    return sevenZFile.read(b);
                                }

                                @Override
                                public int read(byte[] b, int off, int len) throws IOException {
                                    return sevenZFile.read(b, off, len);
                                }
                            },handler,format);
                        }
                    }
                } finally {
                    sevenZFile.close();
                }

            } else {
                InputStream in;

                String archiveCompression = detectCompression(archive);
                InputStream fin = new BufferedInputStream(new FileInputStream(archive));
                if(archiveCompression != null) {
                    if (CompressorStreamFactory.GZIP.equalsIgnoreCase(archiveCompression)) {
                        log.info("auto-detected archive compression: GZIP");
                        in = new GzipCompressorInputStream(fin,true);
                    } else if (CompressorStreamFactory.BZIP2.equalsIgnoreCase(archiveCompression)) {
                        log.info("auto-detected archive compression: BZIP2");
                        in = new BZip2CompressorInputStream(fin, true);
                    } else {
                        in = fin;
                    }
                } else {
                    in = fin;
                }

                ArchiveInputStream zipStream = new ArchiveStreamFactory().createArchiveInputStream(new BufferedInputStream(in));
                logArchiveType(zipStream);

                ArchiveEntry entry;
                while( (entry = zipStream.getNextEntry()) != null) {

                    if(! entry.isDirectory()) {
                        log.info("loading entry {} ...", entry.getName());

                        // detect the file format
                        RDFFormat detectedFormat = Rio.getParserFormatForFileName(entry.getName());
                        if(format == null) {
                            if(detectedFormat != null) {
                                log.info("auto-detected entry format: {}", detectedFormat.getName());
                                format = detectedFormat;
                            } else {
                                throw new RDFParseException("could not detect input format of entry "+ entry.getName());
                            }
                        } else {
                            if(detectedFormat != null && !format.equals(detectedFormat)) {
                                log.warn("user-specified entry format ({}) overrides auto-detected format ({})", format.getName(), detectedFormat.getName());
                            } else {
View Full Code Here

Examples of org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry

        if (f == null) {
            return super.getInputStream();
        }

        final SevenZFile z = new SevenZFile(f);
        SevenZArchiveEntry ze = z.getNextEntry();
        while (ze != null) {
            if (ze.getName().equals(getName())) {
                return new InputStream() {
                    public int read() throws IOException {
                        return z.read();
                    }
                    public int read(byte[] b) throws IOException {
View Full Code Here

Examples of org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry

        }

        SevenZFile z = null;
        try {
            z = new SevenZFile(f);
            SevenZArchiveEntry ze = z.getNextEntry();
            while (ze != null) {
                if (ze.getName().equals(getName())) {
                    setEntry(ze);
                    return;
                }
                ze = z.getNextEntry();
            }
View Full Code Here

Examples of org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry

                                      matchDirEntries);
            return;
        }

        File srcFile = fp.getFile();
        SevenZArchiveEntry entry = null;
        SevenZFile zf = null;

        try {
            try {
                zf = new SevenZFile(srcFile);
                entry = zf.getNextEntry();
                while (entry != null) {
                    /* TODO implement canReadEntryData in CC
                    if (getSkipUnreadableEntries() && !zf.canReadEntryData(entry)) {
                        log(Messages.skippedIsUnreadable(entry));
                        continue;
                    }
                    */
                    Resource r = new SevenZResource(srcFile, encoding, entry);
                    String name = entry.getName();
                    if (entry.isDirectory()) {
                        name = trimSeparator(name);
                        dirEntries.put(name, r);
                        if (match(name)) {
                            matchDirEntries.put(name, r);
                        }
View Full Code Here

Examples of org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry

        FileNameMapper mapper = getMapper();
        SevenZFile outer = null;
        try {
            final SevenZFile zf = outer = new SevenZFile(srcF);
            boolean empty = true;
            SevenZArchiveEntry ze = zf.getNextEntry();
            while (ze != null) {
                empty = false;
                /* TODO implement canReadEntryData in CC
                if (getSkipUnreadableEntries() && !zf.canReadEntryData(ze)) {
                    log(Messages.skippedIsUnreadable(ze));
                    continue;
                }
                */
                log("extracting " + ze.getName(), Project.MSG_DEBUG);
                InputStream is = null;
                try {
                    extractFile(fileUtils, srcF, dir,
                                is = new InputStream() {
                                        public int read() throws IOException {
                                            return zf.read();
                                        }
                                        public int read(byte[] b) throws IOException {
                                            return zf.read(b);
                                        }
                                    },
                                ze.getName(), ze.getLastModifiedDate(),
                                ze.isDirectory(), mapper);
                } finally {
                    FileUtils.close(is);
                }
                ze = zf.getNextEntry();
            }
View Full Code Here

Examples of org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry

                }
            });
        setEntryBuilder(
              new ArchiveBase.EntryBuilder() {
                public ArchiveEntry buildEntry(ArchiveBase.ResourceWithFlags r) {
                    SevenZArchiveEntry entry = new SevenZArchiveEntry();
                    entry.setName(r.getName());
                    entry.setDirectory(r.getResource().isDirectory());
                    entry.setLastModifiedDate(new Date(r.getResource()
                                                       .getLastModified()));
                    entry.setSize(r.getResource().getSize());
                    return entry;
                }
            });
        setFileSetBuilder(new ArchiveBase.FileSetBuilder() {
                public ArchiveFileSet buildFileSet(Resource dest) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.