#
#   unpack.sh  -  extract any archive
#
set file $_passed
set dest ram:
# Uncomment the following line if the default destination directory should
# be where the archive came from:
#
# set dest @pathname( $file )

alias center "%a echo @center( $a 77 )

set w @words( $file )

if $w > 2
 center
 center "Wrong usage... click on AppIcon for help"
 return 0
endif

if $w = 2
 if -d @word( $file 1 )  # first arg is a directory
  set dest @word( $file 1 )
  set file @word( $file 2 )
 else
  set dest @word( $file 2 )
  set file @word( $file 1 )
 endif
endif

if $file <> ""
 class.sh toolmanager
 cd $dest
 action extr $file
 set err $_lasterr
 if $err = 10
  center
  center "I could not determine the type of this file."
 endif
 if $err = 11
  center
  center "I don't know how to unpack this type of file."
 endif
 if $err = 12
  center
  center "I could not execute the program to unpack this file."
 endif
else
 center
 center "* * *  UNPACK  * * *"
 center
 center "If you drop any archive on this icon, it will be unpacked to RAM:.
 center "To specify a destination directory, click on the destination"
 center "drawer/disk, and shift-drag the archive icon on the unpack icon."
 center
 center "You have to select 'Update' from the workbench's 'Window' menu to
 center "see the new files if the destination drawer was already open.
 center
 center "To modify the various programs used for unarchiving, read
 center "the chapter 'object oriented features' in your csh.doc.
 center
 center
 center "Click close button when done
endif
