Changeset 13350 in josm for trunk/src/org


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

see #15816 - add XZ support

Location:
trunk/src/org
Files:
112 added
2 edited

Legend:

Unmodified
Added
Removed
  • 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.