.key FileName

; Archive handling script used by Amiga guide output of AmiSearch II
; Version 1.5 (December 30)
; This script is a part of the AmiSearch II package. It is FORBIDDEN
; to redistribute it alone. If you modify it please send it to me
; and I will consider including it in the AmiSearch II package.
; (c) 1997 Franck ANIERE (aniere@univ-mlv.fr)

; Global initialization : you should customize this part

SET DECOMPDIR   "Ram:"
SET DECOMPDRIVE "Rad:"
SET LHA "C:Lha"
SET LZX "C:Lzx"
SET DMS "C:dms"
SET GFX "Aq1:Gfx/Viewers/Visage MODE 167940"
SET OUT "CON:0/16/640/100/Unpacking archive/CLOSE/WAIT"
SET GUIDEXEC "SYS:Utilities/Multiview"

; Before trying to identify we check its existence

IF NOT EXISTS "<FileName>"
   ECHO "I can't open this file" >$OUT
   QUIT
ENDIF

; Now we should remove path

set TheFileName `BASENAME "<FileName>"`

; First step : test if we have a LHA archive (.lha/.lzh)

SET TheBasename `BASENAME "$TheFileName" .lha`
IF NOT "$TheBasename" EQ "$TheFileName"
  $LHA x "<FileName>" $DECOMPDIR >$OUT
  QUIT
ENDIF

SET TheBasename `BASENAME "$TheFileName" .lzh`
IF NOT "$TheBasename" EQ "$TheFileName"
  $LHA x "<FileName>" $DECOMPDIR >$OUT
  QUIT
ENDIF

; Second step : test if we have a LZX archive

SET TheBasename `BASENAME "$TheFileName" .lzx`
IF NOT "$TheBasename" EQ "$TheFileName"
  $LZX x "<FileName>" $DECOMPDIR >$OUT
  QUIT
ENDIF

; Third step : test if we have a DMS archive

SET TheBasename `BASENAME "$TheFileName" .dms`
IF NOT "$TheBasename" EQ "$TheFileName"
  $DMS WRITE "<FileName>" TO $DECOMPDIR >$OUT
  QUIT
ENDIF

; Now it may be a picture, so let's check...

; First step : GIF picture ?

SET TheBasename `BASENAME "$TheFileName" .gif`
IF NOT "$TheBasename" EQ "$TheFileName"
   $GFX "<FileName>"
   QUIT
ENDIF

; Second step : and why not a JPEG picture ?

SET TheBasename `BASENAME "$TheFileName" .jpg`
IF NOT "$TheBasename" EQ "$TheFileName"
   $GFX "<FileName>"
   QUIT
ENDIF

SET TheBasename `BASENAME "$TheFileName" .jpeg`
IF NOT "$TheBasename" EQ "$TheFileName"
   $GFX "<FileName>"
   QUIT
ENDIF

; Third step : so it may be a PNG picture...

SET TheBasename `BASENAME "$TheFileName" .png`
IF NOT "$TheBasename" EQ "$TheFileName"
   $GFX "<FileName>"
   QUIT
ENDIF

; Fourth step : or maybe an IFF one...

SET TheBasename `BASENAME "$TheFileName" .iff`
IF NOT "$TheBasename" EQ "$TheFileName"
   $GFX "<FileName>"
   QUIT
ENDIF

; Fifth step : and why not a Guide ?

SET TheBasename `BASENAME "$TheFileName" .guide`
IF NOT "$TheBasename" EQ "$TheFileName"
   $GUIDEXEC "<FileName>"
   QUIT
ENDIF



; Mmmm.....this is an unknown file...

ECHO "I can't identify this file format, I copy it to $DECOMPDIR..." >$OUT
COPY >NIL: "<FileName>" $DECOMPDIR
