home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / ppcsmalleiffel / lib_se / clean.e < prev    next >
Encoding:
Text File  |  1998-01-16  |  2.9 KB  |  114 lines

  1. --          This file is part of SmallEiffel The GNU Eiffel Compiler.
  2. --          Copyright (C) 1994-98 LORIA - UHP - CRIN - INRIA - FRANCE
  3. --            Dominique COLNET and Suzanne COLLIN - colnet@loria.fr 
  4. --                       http://www.loria.fr/SmallEiffel
  5. -- SmallEiffel is  free  software;  you can  redistribute it and/or modify it 
  6. -- under the terms of the GNU General Public License as published by the Free
  7. -- Software  Foundation;  either  version  2, or (at your option)  any  later 
  8. -- version. SmallEiffel is distributed in the hope that it will be useful,but
  9. -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  10. -- or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU General Public License 
  11. -- for  more  details.  You  should  have  received a copy of the GNU General 
  12. -- Public  License  along  with  SmallEiffel;  see the file COPYING.  If not,
  13. -- write to the  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  14. -- Boston, MA 02111-1307, USA.
  15. --
  16. class CLEAN -- The command.
  17.  
  18. inherit GLOBALS;
  19.    
  20. creation make
  21.    
  22. feature 
  23.    
  24.    make is
  25.       local
  26.      arg: INTEGER;
  27.      str: STRING;
  28.      
  29.       do
  30.      if argument_count < 1 then
  31.         std_error.put_string("Bad use of command `clean'.%N");
  32.         print_help("clean");
  33.         die_with_code(exit_failure_code);
  34.      end;
  35.      from  
  36.         arg := 1;
  37.      until
  38.         arg > argument_count
  39.      loop
  40.         str := argument(arg);
  41.         if ("-verbose").is_equal(str) then
  42.            echo.set_verbose;
  43.         else
  44.            if str.has_suffix(eiffel_suffix) then
  45.           str.remove_suffix(eiffel_suffix);
  46.            elseif str.has_suffix(make_suffix) then
  47.           str.remove_suffix(make_suffix);
  48.            end;
  49.            if dos_system = system_name then
  50.           from
  51.           until
  52.              str.count <= 4
  53.           loop
  54.              str.remove_last(1);
  55.           end;
  56.            end;
  57.            c_files_removing(str);
  58.            str.to_upper;
  59.            c_files_removing(str);
  60.            str.to_lower;
  61.            c_files_removing(str);
  62.         end;
  63.         arg := arg + 1;
  64.      end;
  65.       end;
  66.  
  67.  
  68.    
  69. feature {NONE}
  70.  
  71.    tmp_string: STRING is
  72.       once
  73.      !!Result.make(256);
  74.       end;
  75.  
  76.    c_files_removing(root: STRING) is
  77.       local
  78.      i: INTEGER;
  79.       do
  80.      from  
  81.         i := 1;
  82.      until
  83.         i = 0
  84.      loop
  85.         tmp_string.copy(root);
  86.         i.append_in(tmp_string);
  87.         tmp_string.append(c_suffix);
  88.         if file_exists(tmp_string) then
  89.            echo.file_removing(tmp_string);
  90.            tmp_string.extend('~');
  91.                echo.file_removing(tmp_string);
  92.            tmp_string.remove_last(1);
  93.            tmp_string.remove_suffix(c_suffix);
  94.            tmp_string.append(o_suffix);
  95.            echo.file_removing(tmp_string);
  96.            i := i + 1;
  97.         else
  98.            i := 0;
  99.         end;
  100.      end;
  101.      tmp_string.copy(root);
  102.      tmp_string.append(h_suffix);
  103.      echo.file_removing(tmp_string);
  104.      tmp_string.copy(root);
  105.      tmp_string.append(c_suffix);
  106.      echo.file_removing(tmp_string);
  107.      tmp_string.copy(root);
  108.      tmp_string.append(make_suffix);
  109.      echo.file_removing(tmp_string);
  110.       end;
  111.  
  112. end -- CLEAN -- The command.
  113.  
  114.