Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to allow output to be a gzip file #16 #17

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Expand Up @@ -15,6 +15,11 @@ IBM Mainframe files on any workstation or laptop etc. that supports Java.

## Updates ##

**Version 5.0.1: March 2024**

- Added support to decompress then recompress into a gzip file if output-file name ends in ".gz"
- Updated pom.xml to have Maven compile using Java 17, and shade the jar.

**Version 5: March 2021**

- Support for variable length binary records. Variable length records processed in binary mode will be prefixed with a 4 byte field in the same format as the IBM RDW i.e. 2 byte record length field (including RDW length, big-endian) followed by 2 bytes of zeros.
Expand All @@ -25,7 +30,7 @@ For execution, TerseDecompress needs a JVM runtime environment.

Usage:

```java -jar tersedecompress-5.0.0.jar [-b] tersed-file output-file```
```java -jar tersedecompress-5.0.1.jar [-b] tersed-file output-file```

Default mode is text mode, which will attempt EBCDIC -> ASCII conversion.

Expand Down
57 changes: 42 additions & 15 deletions pom.xml
Expand Up @@ -5,47 +5,74 @@

<groupId>org.openmainframeproject.tersedecompress</groupId>
<artifactId>tersedecompress</artifactId>
<version>5.0.0</version>
<version>5.0.1</version>
<packaging>jar</packaging>

<name>tersedecompress</name>
<url>https://github.com/openmainframeproject/tersedecompress-testdata</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jdk-release>17</jdk-release>
<junit-version>4.13.1</junit-version>
<maven-compiler-version>3.12.1</maven-compiler-version>
<maven-shade-version>3.5.1</maven-shade-version>
<skipTests>true</skipTests>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>${maven-compiler-version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<release>${jdk-release}</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>org.openmainframeproject.tersedecompress.TerseDecompress</mainClass>
</manifest>
</archive>
</configuration>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven-shade-version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<minimizeJar>true</minimizeJar>
<entryPoints>
<entryPoint>org.openmainframeproject.tersedecompress.TerseDecompress</entryPoint>
</entryPoints>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>org.openmainframeproject.tersedecompress.TerseDecompress</Main-Class>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Expand Up @@ -34,8 +34,12 @@
/* Andrew Rowley, Black Hill Software */
/* Mario Bezzi, Watson Walker */
/*****************************************************************************/
/* Version 6: support for gzipped output records */
/* Russell Shaw */
/*****************************************************************************/

import java.io.*;
import java.util.zip.GZIPOutputStream;

class TerseDecompress {

Expand All @@ -46,7 +50,7 @@ class TerseDecompress {
+"The -b flag turns on binary mode, no conversion will be attempted\n"
);

private static final String Version = new String ("Version 5, March 2021");
private static final String Version = new String ("Version 6, March 2024");

private void printUsageAndExit() {
System.out.println(DetailedHelp);
Expand Down Expand Up @@ -95,15 +99,23 @@ else if (outputFileName == null)
printUsageAndExit();
}

System.out.println("Attempting to decompress input file (" + inputFileName +") to output file (" + outputFileName +")");

if (outputFileName.endsWith(".gz")) {
try (TerseDecompresser outputWriter = TerseDecompresser.create(new FileInputStream(inputFileName), new GZIPOutputStream(new FileOutputStream(outputFileName), 8192, true)))
{
outputWriter.TextFlag = textMode;
outputWriter.decode();
}
}
else {
try (TerseDecompresser outputWriter = TerseDecompresser.create(new FileInputStream(inputFileName), new FileOutputStream(outputFileName)))
{
outputWriter.TextFlag = textMode;
outputWriter.decode();
}
}

try (TerseDecompresser outputWriter
= TerseDecompresser.create(new FileInputStream(inputFileName), new FileOutputStream(outputFileName)))
{
outputWriter.TextFlag = textMode;
System.out.println("Attempting to decompress input file (" + inputFileName +") to output file (" + outputFileName +")");
outputWriter.decode();
}

System.out.println("Processing completed");
}

Expand Down