home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / ppcsmalleiffel / lib_se / binary_file_write.e < prev    next >
Encoding:
Text File  |  1998-01-16  |  1.9 KB  |  76 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 BINARY_FILE_WRITE
  17.  
  18. creation make
  19.  
  20. feature
  21.  
  22.    path: STRING;
  23.  
  24. feature {NONE}
  25.  
  26.    output_stream: POINTER;
  27.  
  28. feature 
  29.  
  30.    make is
  31.       do
  32.       end;
  33.  
  34. feature
  35.  
  36.    connect_to(new_path: STRING) is
  37.       require
  38.      not is_connected;
  39.      not new_path.empty
  40.       do
  41.      output_stream := bfw_open(new_path.count,new_path.to_external);
  42.      if output_stream.is_not_void then
  43.         path := new_path;
  44.      end;
  45.       end;
  46.  
  47.    is_connected: BOOLEAN is
  48.       do
  49.      Result := path /= Void;
  50.       end;
  51.  
  52.    put_byte(byte: CHARACTER) is
  53.       require
  54.      is_connected
  55.       do
  56.      c_inline_c("fputc(b1,C1->_output_stream);");
  57.       end;
  58.  
  59.    disconnect is
  60.       require
  61.      is_connected
  62.       do
  63.      c_inline_c("fclose(C->_output_stream);"); 
  64.      path := Void;
  65.       end;
  66.  
  67. feature {NONE}
  68.  
  69.    bfw_open(path_count: INTEGER; path_pointer: POINTER): POINTER is
  70.       do
  71.      c_inline_c("R=fopen(a2,%"wb%");");
  72.       end;
  73.  
  74. end -- BINARY_FILE_WRITE
  75.  
  76.