Search in sources :

Example 1 with FilteredOutputStream

use of com.mucommander.commons.io.FilteredOutputStream in project mucommander by mucommander.

the class ZipArchiveFile method addEntry.

// ////////////////////////////////////////
// AbstractRWArchiveFile implementation //
// ////////////////////////////////////////
@Override
public synchronized OutputStream addEntry(final ArchiveEntry entry) throws IOException, UnsupportedFileOperationException {
    checkZipFile();
    final ZipEntry zipEntry = createZipEntry(entry);
    if (zipEntry.isDirectory()) {
        // Add the new directory entry to the zip file (physically)
        zipFile.addEntry(zipEntry);
        // Set the ZipEntry object into the ArchiveEntry
        entry.setEntryObject(zipEntry);
        // Declare the zip file and entries tree up-to-date and add the new entry to the entries tree
        finishAddEntry(entry);
        return null;
    } else {
        // Set the ZipEntry object into the ArchiveEntry
        entry.setEntryObject(zipEntry);
        return new FilteredOutputStream(zipFile.addEntry(zipEntry)) {

            @Override
            public void close() throws IOException {
                super.close();
                // Declare the zip file and entries tree up-to-date and add the new entry to the entries tree
                finishAddEntry(entry);
            }
        };
    }
}
Also used : FilteredOutputStream(com.mucommander.commons.io.FilteredOutputStream) ZipEntry(com.mucommander.commons.file.archive.zip.provider.ZipEntry)

Aggregations

ZipEntry (com.mucommander.commons.file.archive.zip.provider.ZipEntry)1 FilteredOutputStream (com.mucommander.commons.io.FilteredOutputStream)1