#!/bin/sh
# IFe_zip
# if no /tmp/ZIP directory and default file create...
if test ! -d /tmp/ZIP ; then
  mkdir /tmp/ZIP
fi
if test ! -f /tmp/ZIP/default.zip ; then
  cp ${IFE_HOME}/misc/ZIP/default.zip /tmp/ZIP/default.zip
fi

# see if xzip is available on this machine, if
# so then run it otherwise show an image
if test ! -f ${IFE_HOME}/sys/bin/xzip ; then
	echo    "emulation	xzip	${IFE_HOME}/lib/images/xzip_image.xwd"
	xwud -in ${IFE_HOME}/lib/images/xzip_image.xwd

# get petri to shift token to the subsequent transition.
echo "shift_next_transition"

# store the current default zip file.
schema=`${IFE_HOME}/sys/bin/dialog -p "Name of the zip file you created?" -file "/tmp/ZIP/default.zip " -d "/tmp/ZIP/default.zip " -h1 "The file created by zip must have been" -h2 "saved in esp mode for it to be readable." -h3 "choose the default if in doubt."`
	echo	"store	zip	zip	zip	$schema"
	exit 0
fi

cd /tmp/ZIP
${IFE_HOME}/sys/bin/xzip

# get petri to shift token to the subsequent transition.
echo "shift_next_transition"

# Ask user what they just created.
schema=`${IFE_HOME}/sys/bin/dialog -p "Name of the zip file you created?" -file "/tmp/ZIP/   " -d "/tmp/ZIP/default.zip " -h1 "The file must have been saved in esp" -h2 "mode for it to be readable. Give the name unknown if" -h3 "nothing. Choose the default if in doubt."`
if [ ! Y$schema = Y ]; then
	if [ $schema = 'unknown' ]; then
		echo	"unknown schema will not be stored..."
	else
		echo	"store	zip	zip	zip	$schema"
	fi
fi
exit 0
