home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rexxalgo.zip / TESTALGO / MakePath.CMD < prev    next >
OS/2 REXX Batch file  |  1997-08-25  |  3KB  |  89 lines

  1. /* REXX **********************************************/
  2. /*                                                   */
  3. /* Program name: MakePath.CMD                        */
  4. /* Function    : Recursive directory path creating   */
  5. /* Syntax      : Call MakePath _destPath             */
  6. /* Changes     : No                                  */
  7. /*                                                   */
  8. /* Made use of GREED.  28 Dec 1996 / 00:39:39   JRK  */
  9. /*****************************************************/
  10. /* (C) Copyright Janosch R. Kowalczyk, 1996.         */
  11. /* All rights reserved.                              */
  12. /*****************************************************/
  13. Parse Source . calledAs .
  14. If calledAs \= "COMMAND" Then 
  15.   Parse Arg _destPath .
  16. Else 
  17.   Parse Arg _destPath, .
  18.  
  19. /*===============(Exception handling)================*/
  20. Signal On Failure  Name CLEARUP
  21. Signal On Halt     Name CLEARUP
  22. Signal On Syntax   Name CLEARUP
  23. Signal On NotReady Name CLEARUP
  24.  
  25. /*===========(Initialize RexxUtil support)===========*/
  26. If RxFuncQuery('SysLoadFuncs') Then Do
  27.   Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  28.   Call SysLoadFuncs
  29. End /* If RxFuncQuery... */
  30.  
  31. Say 
  32. Say Center( "( RECURSIVE DIRECTORY PATH CREATING )", 80, '*')
  33.  
  34. If _destPath = '' Then 
  35.   _destPath = 'C:\TEST\MAKE\PATH\PROCEDUR\RECURSIV\NEW\TEST'
  36.  
  37. Call MakePath _destPath 
  38.  
  39. Call LineOut , "Press any key to exit "
  40. Call LineIn
  41.  
  42. /*================(End this program)================*/
  43. Exit
  44.  
  45. CLEARUP:
  46.   Say
  47.   Say 'GREED001E - Break, Failure or Syntax Error'
  48. Exit
  49.  
  50.  
  51.  
  52. /*=============( Recursive Path Creating )============*/
  53. /*                                                 16 */
  54. /* Name.......: MakePath                              */
  55. /*                                                    */
  56. /* Function...: Create recursive directory path       */
  57. /*                                                    */
  58. /* Call parm..: _destPath  - directory path           */
  59. /*                                                    */
  60. /* Returns....: formated string                       */
  61. /*                                                    */
  62. /* Syntax.....:                                       */
  63. /*    _destPath = MakePath( _destPath )               */
  64. /*                                                    */
  65. /* Changes....: No                                    */
  66. /*                                                    */
  67. /* Author.....: Janosch R. Kowalczyk                  */
  68. /*====================================================*/
  69. /*---------------(Create Directory Path)--------------*/
  70. MakePath: Procedure
  71. Arg _destPath
  72.  
  73. _destPath = Strip(_destPath,,'\')
  74. If Pos('\', _destPath) = 0 Then Return _destPath
  75.  
  76. /*--------------( Check Directory Path )--------------*/
  77. rc = SysFileTree( _destPath, fileList, 'DO' )
  78. If fileList.0 = 0 Then Do
  79.   /*------------(Directory path not exists)-----------*/
  80.   Call MakePath SubStr(_destPath, 1, LastPos('\', _destPath))  
  81.   rc = SysMkDir( _destPath )
  82.   If rc > 0 & rc \= 5 Then
  83.     Say 'Destination directory:' _destPath 'not created. RC=' rc 
  84.   Else 
  85.     Say _destPath 'successful created'
  86. End
  87.  
  88. Return _destPath
  89.