/* ***************************************************** */ /* Unzip the contents of a zip file into a subdirectory */ /* with the zip file's name. */ /* A target folder can optionally be specified. */ /* */ /* This requires 'unzip.exe' to be in your path */ /* */ /* Author : L. Van Bogaert, 2002 */ /* ***************************************************** */ /* ----------------------------------------------------- */ /* load required RexxUtil functions */ /* ----------------------------------------------------- */ call RxFuncAdd 'SysOpenObject', 'RexxUtil', 'SysOpenObject' call RxFuncAdd 'SysSetObjectData', 'RexxUtil', 'SysSetObjectData' /* ----------------------------------------------------- */ /* read script parameters */ /* ----------------------------------------------------- */ parse arg sourcepath targetpath if sourcepath = '' then signal nosourcepath if stream(sourcepath, 'c', 'query exists') = '' then signal nosourcefile /* ----------------------------------------------------- */ /* set target path if no or invalid path was specified */ /* ----------------------------------------------------- */ if targetpath = '' | translate(targetpath) <> translate(directory(targetpath)) then targetpath = left(sourcepath, lastpos('\', sourcepath) - 1) /* ----------------------------------------------------- */ /* set name of target folder (based on name of zip file) */ /* ----------------------------------------------------- */ filename = substr(sourcepath,lastpos('\', sourcepath) + 1) if lastpos('.', filename) = 0 then targetfolder = filename else targetfolder = left(filename, lastpos('.', filename) - 1) /* ----------------------------------------------------- */ /* create target folder to hold contents of zip file */ /* ----------------------------------------------------- */ 'mkdir' targetpath'\'targetfolder /* ----------------------------------------------------- */ /* unzip archive into target folder */ /* ----------------------------------------------------- */ 'unzip -u' sourcepath '-d' targetpath'\'targetfolder /* ----------------------------------------------------- */ /* set target folder attributes */ /* ----------------------------------------------------- */ call SysSetObjectData targetpath'\'targetfolder, "ICONVIEWPOS=20,55,50,30" call SysSetObjectData targetpath'\'targetfolder, "BACKGROUND=?:\os2\bitmap\zipbkgrd.bmp,T,1,I" call SysSetObjectData targetpath'\'targetfolder, "ALWAYSSORT=YES" /* ----------------------------------------------------- */ /* open the target folder in default view */ /* ----------------------------------------------------- */ call SysOpenObject targetpath'\'targetfolder, 'default', 'true' /* ----------------------------------------------------- */ /* force refresh of the target folder */ /* ----------------------------------------------------- */ call SysSetObjectData fulldirname, 'MENUITEMSELECTED=503' signal exit nosourcepath: say 'Unpack - Missing argument' signal exit nosourcefile: say 'Unpack - Source file not found' signal exit exit: exit