home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / wps / system / deskman / cleanup.cmd next >
Encoding:
Text File  |  1993-03-25  |  3.3 KB  |  88 lines

  1. /*─REXX─OS/2───────────────────────────────────────────────────────────────────┐
  2. │  CleanUp.CMD - part of DesktopManager (DeskMan/2) for OS/2                   │
  3. │                Removes unused *.ICO files for a specified directory.         │
  4. │  Mar. 25, 93   Handle root directories properly                              │
  5. │  Copyright:    Greg Czaja & Development Technologies, Inc. 1993              │
  6. └─────────────────────────────────────────────────────────────────────────────*/
  7.  
  8. Call RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs';
  9. Call SysLoadFuncs;           
  10. Parse Arg _dir _ico_dir             /* directory can be specified on  call?   */
  11.  
  12. If _dir='/?' | _dir='-?'            /* Help requested?                        */
  13.    Then Do;
  14.      Say '';
  15.      Say 'CleanUp.CMD (part of DeskMan/2) can be used to remove stored ICO files';
  16.      Say 'which are not needed anymore.';
  17.      Say 'Use: ';
  18.      Say '        CLEANUP <directory> <icon_directory>';
  19.      Say 'to remove all ICO files from the specified directory or the current';
  20.      Say 'directory, if <icon_directory> was not specified.';
  21.      Say 'All DRC and CMD files located in <directory> (or the current directory,';
  22.      Say 'if <directory> was not specified) will be searched for ICO files used -';
  23.      Say 'if an ICO file is not referenced by any of them, it will be removed.';
  24.      Say '';
  25.      Exit;
  26.      End;
  27.  
  28. If _dir='' Then _dir=Directory();    /* was the directory specified on call?   */
  29.                                     /* if not, use the current one            */
  30. If _ico_dir='' Then _ico_dir=Directory();   
  31. If Right(_dir, 1) \= '\'
  32.    Then _dir=_dir||'\';
  33. If Right(_ico_dir, 1) \= '\'
  34.    Then _ico_dir=_ico_dir||'\';
  35.  
  36. rc=SysFileTree(_dir||'*.CMD', 'files.', 'FO');
  37. If rc <> 0                          /* look for all the CMD files             */
  38.    Then Do;
  39.      Say 'CleanUp.CMD - Unexpected error!';
  40.      Exit 99;
  41.      End;
  42.  
  43. icons.=0;
  44. Call FindIcons;                     /* grab all icons used                    */
  45.  
  46. rc=SysFileTree(_dir||'*.DRC', 'files.', 'FO');
  47. If rc <> 0                          /* look for all the DRC files             */
  48.    Then Do;
  49.      Say 'CleanUp.CMD - Unexpected error!';
  50.      Exit 99;
  51.      End;
  52. Call FindIcons;                     /* grab the icons used                    */
  53.  
  54. rc=SysFileTree(_ico_dir||'*.ICO', 'files.', 'FO');
  55. If rc <> 0                          /* get all the ICO files now...           */
  56.    Then Do;
  57.      Say 'CleanUp.CMD - Unexpected error!';
  58.      Exit 99;
  59.      End;
  60.  
  61. Do i=1 to files.0;                  /* do the checking now                    */
  62.    icon=Translate(files.i);
  63.    If icons.icon Then Iterate;      /* it is referenced somewhere             */
  64.    '@ERASE 'icon;                   /* it's not - delete...                   */
  65. End;
  66.  
  67. Exit 0;
  68.  
  69. FindIcons: Procedure Expose icons. files.
  70.  
  71. Do i=1 to files.0;                  /* scann all the files for ICONFILEs      */
  72.    rc=SysFileSearch('ICONFILE=', files.i, 'lines.');
  73.    If rc <> 0
  74.      Then Do;
  75.        Say 'CleanUp.CMD - Unexpected error reading: 'files.i'!';
  76.        Exit 99;
  77.        End;
  78.    Do j=1 to lines.0;
  79.       Parse Var lines.j 'ICONFILE=' _ico ';' .
  80.       k=icons.0+1;
  81.       icons.0=k;
  82.       _ico=Translate(_ico);
  83.       icons._ico=1;
  84.    End;
  85. End;
  86.  
  87. Return;
  88.