Changeset 13350 in josm


Ignore:
Timestamp:
2018-01-21T22:05:06+01:00 (4 months ago)
Author:
stoecker
Message:

see #15816 - add XZ support

Location:
trunk
Files:
112 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/CONTRIBUTION

    r13231 r13350  
    7171with the New (2-clause) BSD license.
    7272
     73The XZ code (https://tukaani.org/xz/java.html)
     74is from Lasse Collin and Igor Pavlov
     75and license free Public Domain.
     76
    7377------------------------------- PROJECTION DATA -------------------------------
    7478
  • trunk/README

    r13323 r13350  
    212212    src/org/jdesktop/swinghelper/debug/CheckThreadViolationRepaintManager.java
    213213    -> https://github.com/floscher/swinghelper
     214* xz extractor
     215    src/org/tukaani
     216    -> https://tukaani.org/xz/java.html
  • trunk/build.xml

    r13304 r13350  
    251251            <exclude name="org/apache/commons/compress/compressors/bzip2/BZip2Utils.java"/>
    252252            <exclude name="org/apache/commons/compress/compressors/brotli/**"/>
    253             <exclude name="org/apache/commons/compress/compressors/lzma/**"/>
    254             <exclude name="org/apache/commons/compress/compressors/xz/**"/>
    255253            <exclude name="org/apache/commons/compress/compressors/CompressorStreamFactory.java"/>
    256254            <exclude name="org/apache/commons/compress/compressors/CompressorStreamProvider.java"/>
  • trunk/src/org/openstreetmap/josm/actions/ExtensionFileFilter.java

    r13329 r13350  
    410410            String extensions, String defaultExtension, String description, boolean addArchiveExtensionsToDescription) {
    411411
    412         List<String> archiveExtensions = Arrays.asList("gz", "bz2");
     412        List<String> archiveExtensions = Arrays.asList("gz", "bz", "bz2", "xz", "zip");
    413413        return newFilterWithArchiveExtensions(
    414414            extensions,
  • trunk/src/org/openstreetmap/josm/io/Compression.java

    r13204 r13350  
    1616import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
    1717import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream;
     18import org.apache.commons.compress.compressors.xz.XZCompressorInputStream;
     19import org.apache.commons.compress.compressors.xz.XZCompressorOutputStream;
    1820import org.openstreetmap.josm.tools.Logging;
    1921import org.openstreetmap.josm.tools.Utils;
     
    3840     * zip compression
    3941     */
    40     ZIP;
     42    ZIP,
     43    /**
     44     * xz compression
     45     */
     46    XZ;
    4147
    4248    /**
     
    5258                : name != null && name.endsWith(".zip")
    5359                ? ZIP
     60                : name != null && name.endsWith(".xz")
     61                ? XZ
    5462                : NONE;
    5563    }
     
    6876        case "application/x-bzip2":
    6977            return BZIP2;
     78        case "application/x-xz":
     79            return XZ;
    7080        default:
    7181            return NONE;
     
    8898            case ZIP:
    8999                return getZipInputStream(in);
     100            case XZ:
     101                return getXZInputStream(in);
    90102            case NONE:
    91103            default:
    92104                return in;
    93105        }
     106    }
     107
     108    /**
     109     * Returns a XZ input stream wrapping given input stream.
     110     * @param in The raw input stream
     111     * @return a XZ input stream wrapping given input stream, or {@code null} if {@code in} is {@code null}
     112     * @throws IOException if the given input stream does not contain valid BZ2 header
     113     * @since 13350
     114     */
     115    public static XZCompressorInputStream getXZInputStream(InputStream in) throws IOException {
     116        if (in == null) {
     117            return null;
     118        }
     119        return new XZCompressorInputStream(in, true);
    94120    }
    95121
     
    173199            case ZIP:
    174200                return new ZipOutputStream(out, StandardCharsets.UTF_8);
     201            case XZ:
     202                return new XZCompressorOutputStream(out);
    175203            case NONE:
    176204            default:
Note: See TracChangeset for help on using the changeset viewer.