home *** CD-ROM | disk | FTP | other *** search
- /*
- * INSTALL.CMD
- *
- * This handy little program will take as input a program to execute and a
- * drive and directory from whence to execute it. It will then ask the user
- * if that is the directory of choice, and, if it is not, get a valid path
- * from said user. If the directory does not exist it is created (after
- * asking, of course). The current directory is changed then the specified
- * program (assumed to be in the same directory as this program, or including
- * a path from this directory) is executed. When the program returns the
- * current directory is restored to the original directory.
- *
- * The program takes three parameters: the program to execute followed by the
- * directory to execute it in and the "name" of the program. For example:
- *
- * INSTALL UTILITY C:\MYPROG\UTILITY /My very own utility program/
- * ------- ----------------- ---------------------------
- * Program name ^ ^ ^
- * Execution Directory | |
- * name of the program |
- *
- * For this time 'round no error checking is done. It is assumed the input
- * parameters are golden.
- *
- * NOTE: for this application I assumed the program being run is a self-
- * extracting ZIP file, and hard-coded stuff that relies on that.
- */
-
- Trace off
- Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
- Call SysLoadFuncs
-
- Parse arg prog dir '/' title '/' .
-
- /* Ask the user if we should use the specified directory. */
- CLS
- target = ''
- overwrite = 'false'
- Do While target = ''
- Say 'Specify the directory you want ' || title || ' to be installed in'
- Say ' (the default directory is ' || dir || ').'
- Say ' Type QUIT to quit this installation.'
- Pull target
- If target = 'QUIT' | target = 'Q' Then
- exit(0)
-
- If target = '' Then
- target = dir
-
- /* Check for the existence of this directory */
- CALL SysFileTree target, 'list', 'DO'
- If list.0 = 0 Then
- Do
- Say 'The directory ' || target || ' does not exist.'
- Say 'Would you like to create it (Y/N)?'
- Pull ans
- If ans = 'Y' Then
- Do
- rc = SysMkDir( target )
- If rc \= 0 Then
- Do
- Say 'ERROR: Could not create directory ' || target || '.'
- Say ' Make sure the drive and path to it exists.'
- dir = target
- target = ''
- Iterate
- End
- Else
- Say 'Directory ' || target || ' created.'
- End
- Else
- Do
- If ans \= 'N' Then
- Say "I'll presume that means NO."
- Say ''
- target = ''
- Iterate
- End
- End
-
- /* Check to see if the directory is empty */
- CALL SysFileTree target || '\*.*', 'list', 'FO'
- If list.0 \= 0 Then
- Do
- Say 'The directory ' || target || ' is not empty.'
- Say 'Do you want to overwrite the files currently there (Y/N)?'
- Pull ans
- If ans = 'Y' Then
- overwrite = 'true'
- Else
- Do
- If ans \= 'N' Then
- Say "I'll presume that means NO."
- Say ''
- target = ''
- Iterate
- End
- End
- End
-
- /* If we got this far we must have a valid directory */
- x = SetLocal() /* Save the current directory */
- currdir = Directory()
- x = Directory( target ) /* Move to the new directory */
-
- /* NOTE!!!!!!!!!!!!!!!!! hardcoded ZIP stuff!!!!!!!!!!!!! */
- If overwrite = 'true' Then
- '@' || currdir || '\' || prog || ' -d -o'
- Else
- '@' || currdir || '\' || prog || ' -d'
-
- x = EndLocal()
-