Example usage for org.apache.commons.compress.archivers.sevenz SevenZArchiveEntry getLastModifiedDate

List of usage examples for org.apache.commons.compress.archivers.sevenz SevenZArchiveEntry getLastModifiedDate

Introduction

In this page you can find the example usage for org.apache.commons.compress.archivers.sevenz SevenZArchiveEntry getLastModifiedDate.

Prototype

@Override
public Date getLastModifiedDate() 

Source Link

Document

Gets the last modified date.

Usage

From source file:com.github.n_i_e.dirtreedb.SevenZipListerForFile.java

@Override
protected PathEntry getNext() throws IOException {
    SevenZArchiveEntry z = sevenzfile.getNextEntry();
    if (z == null) {
        return null;
    }/*from   ww w .  ja  v a 2s  . com*/
    int newtype = z.isDirectory() ? PathEntry.COMPRESSEDFOLDER : PathEntry.COMPRESSEDFILE;
    String s = z.getName();
    if (s == null) {
        s = AbstractCompressorLister.getBasename(getBasePath());
    }
    ;
    s = s.replace("\\", "/");
    if (z.isDirectory() && !s.endsWith("/")) {
        s = s + "/";
    }
    PathEntry next_entry = new PathEntry(getBasePath().getPath() + "/" + s, newtype);
    next_entry.setDateLastModified(z.getLastModifiedDate().getTime());
    next_entry.setStatus(PathEntry.DIRTY);
    next_entry.setSize(z.getSize());
    next_entry.setCompressedSize(z.getSize());
    if (isCsumRequested() && newtype == PathEntry.COMPRESSEDFILE) {
        next_entry.setCsum(new SevenZipInputStream());
    }
    if (next_entry.getSize() < 0) {
        next_entry.setSize(0);
    }
    if (next_entry.getCompressedSize() < 0) {
        next_entry.setCompressedSize(next_entry.getSize());
    }
    return next_entry;
}

From source file:com.izforge.izpack.util.compress.SevenZArchiveInputStream.java

@Override
public ArchiveEntry getNextEntry() throws IOException {
    final SevenZArchiveEntry sevenZArchiveEntry = zFile.getNextEntry();

    currentEntry = sevenZArchiveEntry;//from   w ww .j  av  a 2 s.  c  o m
    currentBytesRead = 0;

    if (sevenZArchiveEntry != null) {
        return new ArchiveEntry() {
            @Override
            public String getName() {
                return sevenZArchiveEntry.getName();
            }

            @Override
            public long getSize() {
                return sevenZArchiveEntry.getSize();
            }

            @Override
            public boolean isDirectory() {
                return sevenZArchiveEntry.isDirectory();
            }

            @Override
            public Date getLastModifiedDate() {
                return sevenZArchiveEntry.getLastModifiedDate();
            }
        };
    }

    return null;
}

From source file:org.apache.ant.compress.taskdefs.Un7z.java

protected void expandFile(FileUtils fileUtils, File srcF, File dir) {
    if (!srcF.exists()) {
        throw new BuildException("Unable to expand " + srcF + " as the file does not exist", getLocation());
    }// w  w  w. j  a  v  a  2 s  . c  om
    log("Expanding: " + srcF + " into " + dir, Project.MSG_INFO);
    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();
        }
        if (empty && getFailOnEmptyArchive()) {
            throw new BuildException("archive '" + srcF + "' is empty");
        }
        log("expand complete", Project.MSG_VERBOSE);
    } catch (IOException ioe) {
        throw new BuildException("Error while expanding " + srcF.getPath() + "\n" + ioe.toString(), ioe);
    } finally {
        if (outer != null) {
            try {
                outer.close();
            } catch (IOException ex) {
                // swallow
            }
        }
    }
}