home *** CD-ROM | disk | FTP | other *** search
- /*─REXX─OS/2───────────────────────────────────────────────────────────────────┐
- │ CleanUp.CMD - part of DesktopManager (DeskMan/2) for OS/2 │
- │ Removes unused *.ICO files for a specified directory. │
- │ Mar. 25, 93 Handle root directories properly │
- │ Copyright: Greg Czaja & Development Technologies, Inc. 1993 │
- └─────────────────────────────────────────────────────────────────────────────*/
-
- Call RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs';
- Call SysLoadFuncs;
- Parse Arg _dir _ico_dir /* directory can be specified on call? */
-
- If _dir='/?' | _dir='-?' /* Help requested? */
- Then Do;
- Say '';
- Say 'CleanUp.CMD (part of DeskMan/2) can be used to remove stored ICO files';
- Say 'which are not needed anymore.';
- Say 'Use: ';
- Say ' CLEANUP <directory> <icon_directory>';
- Say 'to remove all ICO files from the specified directory or the current';
- Say 'directory, if <icon_directory> was not specified.';
- Say 'All DRC and CMD files located in <directory> (or the current directory,';
- Say 'if <directory> was not specified) will be searched for ICO files used -';
- Say 'if an ICO file is not referenced by any of them, it will be removed.';
- Say '';
- Exit;
- End;
-
- If _dir='' Then _dir=Directory(); /* was the directory specified on call? */
- /* if not, use the current one */
- If _ico_dir='' Then _ico_dir=Directory();
- If Right(_dir, 1) \= '\'
- Then _dir=_dir||'\';
- If Right(_ico_dir, 1) \= '\'
- Then _ico_dir=_ico_dir||'\';
-
- rc=SysFileTree(_dir||'*.CMD', 'files.', 'FO');
- If rc <> 0 /* look for all the CMD files */
- Then Do;
- Say 'CleanUp.CMD - Unexpected error!';
- Exit 99;
- End;
-
- icons.=0;
- Call FindIcons; /* grab all icons used */
-
- rc=SysFileTree(_dir||'*.DRC', 'files.', 'FO');
- If rc <> 0 /* look for all the DRC files */
- Then Do;
- Say 'CleanUp.CMD - Unexpected error!';
- Exit 99;
- End;
- Call FindIcons; /* grab the icons used */
-
- rc=SysFileTree(_ico_dir||'*.ICO', 'files.', 'FO');
- If rc <> 0 /* get all the ICO files now... */
- Then Do;
- Say 'CleanUp.CMD - Unexpected error!';
- Exit 99;
- End;
-
- Do i=1 to files.0; /* do the checking now */
- icon=Translate(files.i);
- If icons.icon Then Iterate; /* it is referenced somewhere */
- '@ERASE 'icon; /* it's not - delete... */
- End;
-
- Exit 0;
-
- FindIcons: Procedure Expose icons. files.
-
- Do i=1 to files.0; /* scann all the files for ICONFILEs */
- rc=SysFileSearch('ICONFILE=', files.i, 'lines.');
- If rc <> 0
- Then Do;
- Say 'CleanUp.CMD - Unexpected error reading: 'files.i'!';
- Exit 99;
- End;
- Do j=1 to lines.0;
- Parse Var lines.j 'ICONFILE=' _ico ';' .
- k=icons.0+1;
- icons.0=k;
- _ico=Translate(_ico);
- icons._ico=1;
- End;
- End;
-
- Return;