This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-compress.git
commit 4fb9620098f81ed68167b298cb1f5f1cd31d0563 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Sun Oct 29 09:44:49 2023 -0400 Add SevenZOutputFile.putArchiveEntry(SevenZArchiveEntry) and deprecate putArchiveEntry(ArchiveEntry) --- src/changes/changes.xml | 1 + .../commons/compress/archivers/examples/Archiver.java | 3 ++- .../compress/archivers/sevenz/SevenZOutputFile.java | 17 ++++++++++++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 85550977..0df7e959 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -63,6 +63,7 @@ The <action> type attribute can be add,update,fix,remove. <action type="add" dev="ggregory" due-to="Gary Gregory">Add GzipUtils.getCompressedFileName(String) and deprecate getCompressedFilename(String).</action> <action type="add" dev="ggregory" due-to="Gary Gregory">Add GzipUtils.getUncompressedFileName(String) and deprecate getUncompressedFilename(String).</action> <action type="add" dev="ggregory" due-to="Gary Gregory">Add GzipUtils.isCompressedFileName(String) and deprecate isCompressedFilename(String).</action> + <action type="add" dev="ggregory" due-to="Gary Gregory">Add SevenZOutputFile.putArchiveEntry(SevenZArchiveEntry) and deprecate putArchiveEntry(ArchiveEntry).</action> <!-- FIX --> <action type="fix" dev="ggregory" due-to="Gary Gregory">Precompile regular expression in ArArchiveInputStream.isBSDLongName(String).</action> <action type="fix" dev="ggregory" due-to="Gary Gregory">Precompile regular expression in ArArchiveInputStream.isGNULongName(String).</action> diff --git a/src/main/java/org/apache/commons/compress/archivers/examples/Archiver.java b/src/main/java/org/apache/commons/compress/archivers/examples/Archiver.java index cd6f137a..5c595d81 100644 --- a/src/main/java/org/apache/commons/compress/archivers/examples/Archiver.java +++ b/src/main/java/org/apache/commons/compress/archivers/examples/Archiver.java @@ -39,6 +39,7 @@ import org.apache.commons.compress.archivers.ArchiveEntry; import org.apache.commons.compress.archivers.ArchiveException; import org.apache.commons.compress.archivers.ArchiveOutputStream; import org.apache.commons.compress.archivers.ArchiveStreamFactory; +import org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry; import org.apache.commons.compress.archivers.sevenz.SevenZOutputFile; import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; import org.apache.commons.compress.utils.IOUtils; @@ -168,7 +169,7 @@ public class Archiver { Objects.requireNonNull(attrs); final String name = directory.relativize(path).toString().replace('\\', '/'); if (!name.isEmpty()) { - final ArchiveEntry archiveEntry = target.createArchiveEntry(path, + final SevenZArchiveEntry archiveEntry = target.createArchiveEntry(path, isFile || name.endsWith("/") ? name : name + "/"); target.putArchiveEntry(archiveEntry); if (isFile) { diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFile.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFile.java index 8d6589a5..9dc622f1 100644 --- a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFile.java +++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFile.java @@ -379,9 +379,24 @@ public class SevenZOutputFile implements Closeable { * {@link #closeArchiveEntry()} to complete the process. * * @param archiveEntry describes the entry + * @deprecated Use {@link #putArchiveEntry(SevenZArchiveEntry)}. */ + @Deprecated public void putArchiveEntry(final ArchiveEntry archiveEntry) { - files.add((SevenZArchiveEntry) archiveEntry); + putArchiveEntry((SevenZArchiveEntry) archiveEntry); + } + + /** + * Records an archive entry to add. + * + * The caller must then write the content to the archive and call + * {@link #closeArchiveEntry()} to complete the process. + * + * @param archiveEntry describes the entry + * @since 1.25.0 + */ + public void putArchiveEntry(final SevenZArchiveEntry archiveEntry) { + files.add(archiveEntry); } /**