iSeries home   |   Easy400     |   CGIDEV2     |   MMAIL  
Public Source
 
 Introduction
 
  Commands:
zipsave
dspzipsave
unzipsave
 
 Display the Change Log
 
 Download
 
 

 
ZIPSAVE
Save & Zip
by Giovanni B. Perotti (Italy)
 
According to our tests, ZIPSAVE compresses a save file 20% more than what system SAV... commands can do with DTACPR(*HIGH).

In addition, with ZIPSAVE ZIP files you enjoy the advantage of a standard compression format across most platforms.

This tool features three commands:

  1. ZIPSAVE - Saves libraries, library objects or IFS objects to an uncompressed save file, then compresses the save file into a standard ".zip" stream file
  2. UNZIPSAVE - Decompresses (unzips) a ".zip" save file and optionally restores objects from that save file
  3. DSPZIPSAVE - Display the table of contents of a ".zip" stream file.
. To compress / decompress save files, commands ZIPSAVE and UNZIPSAVE can use - upon user choice - one of the following tools:
  • Command Jar, available in the IBMi Qshell, whatever release, OR
  • CL commands CPYTOARCF (Copy to Archive File) and CPYFRMARCF (Copy from ArchiveFile), available on IBMi starting with release V7R2.
Command DSPZIPSAVE can just use command Jar, as so far there is no CL command to display the list of contents of a zip stream file.

About iSeries QShell

iSeries QSHELL is a command line interpreter (shell) running on the IBM iSeries computer platform. Qshell is based on POSIX and X/Open standards. IBM created the Qshell interpreter primarily to provide support for the Java Development Kit (JDK) on their iSeries line of computers. The Qshell interpreter can be used interactively or for running shell scripts.

Links: Qshell in the IBM i Knowledge Center (html)
Exploring iSeries QShell (html)
IBM System i - Programming QShell (pdf)

About the "JAR" tool

The "JAR" (Java ARchive) tool - available trough the QShell interpreter - combines multiple files by compressing them into a single jar file.
It is compatible with the jar tool that is supplied by Sun Microsystems, Inc. which was designed mainly to facilitate the packaging of java applets or applications into a single archive.
JAR files are based on the ZIP file format.
Links: ZIP (file format) (html)
jar - The Java Archive tool (html)

Some findings about the "JAR" tool on iSeries

The following are some findings of mine when I tried to use JAR for the first time and are provided just for reader information.
All potential problems are solved in ZIPSAVE commands.

After reading Thomas Snyder's technical tip Use RPG and QShell for Zipping and Tarring Files, I got the impression that I could use the JAR tool to compress any type of OS/400 file, from an IFS stream file, to a source member.
You can try and believe in success, until you try to decompress (unzip) the compressed files.

The problem here is that the information about the codepage of the compressed files is not retained (the underlying assumption here seems to be that the whole game is for PC objects).
Therefore, when a zipped file is decompressed (inflated), it is given codepage 819 (PC ASCII) whatever its original code page was.
Of course you may then copy the decompressed stream file to another stream file, by specifying the correct target codepage, but that implies that you know what it was.

The next problem is when you want the resulting zip file be processed on a PC. In such a case the zip file (the JAR file) must be codepage 819 (PC ASCII), otherwise the PC unzip utility would not understand it.

In conclusion:

  1. If you want the zipped files be processed by a PC, you must use codepage 819 both for the containing file (the zip or JAR file) and for the contained files (the zipped ones) if they must be accessed by PC users or PC programs.
    To convert both a stream file external CCSID label and its internal data to another CCSID, use command CPY. Example:
    CPY OBJ('/tmp/a') TOOBJ('/tmp/a') TOCCSID(819) DTAFMT(*TEXT/*BINARY) REPLACE(*YES)
  2. Zipped files containing binary data (as save files) must be codepage 819 to be understood by a PC, but do not need to be converted to such a codepage. When back to an OS/400 save file, they will be understood again in their original 65535 CCSID.
    To convert only the stream file external CCSID label leaving its internal data with their original CCSID, use command CHGATR. Example:
    CHGATR OBJ('/tmp/a') ATR(*CCSID) VALUE(819)
  3. Text files to be unzipped and read on a PC, must be converted as *text to codepage 819 before they are zipped.
  4. PDF stream files must be converted as *binary to codepage 819 before they are zipped.


What is the ZIPSAVE utility

ZIPSAVE is an iSeries public-source utility available from the Easy400 site.
It was made for distributing save files through the Internet network.
It does take advantage of the iSeries Qshell JAR utility or V7R2 CL commands CPYTOARCF and CPYFRMARCF in order to distribute save files in compressed format.
Zip files generated by this utility can be unzipped on a PC or directly on an iSeries.
The overall contents of a ZIPSAVE generated zip stream file are:
• an optional .txt file containing some installation instructions
• a .savf binary file that can be used to load an iSeries save file.

The ZIPSAVE utility is made of the following commands:

  1. ZIPSAVE
    Allows to run a SAVLIB, a SAVOBJ or a SAV command.
    The QShell JAR tool or CL command CPYTOARCF is used to compress the resulting save file into a user-specified zip file along with a "readme" user-specified text stream file.
     Note- The command takes care of the 819 codepage for both files.
  2. DSPZIPSAVE
    The QShell JAR tool is used to display the table of contents of the zip file.
  3. UNZIPSAVE
    The ZIPSAVE-created zip file can be unzipped on a PC.
    The UNZIPSAVE command uses the Qshell JAR tool or the CL command CPYFRMARCF to performs the unzip on the iSeries.
    Options are available to display the optional "readme" text file and to upload a QGPL save file from the unzipped save stream file.

Command helps provide the detail information needed to properly operate.

See the next pages for details. next page

Installing the ZIPSAVE utility

The download file of this utility contains an installation instructions page. Basically you should
  • Upload to your IBM System i the save file of library ZIPSAVE
  • Restore library ZIPSAVE
  • Start a REXX procedure which creates ZIPSAVE objects from their sources.
To validate the utility, you should try a ZIPSAVE command.
This should not give you troubles.
However, if the QShell command entry shows you some weird messages, you may be missing some PTF(s). I myself had a case with a V7R2 box, see this page.