home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_se / binary_file_write.e < prev    next >
Text File  |  1999-06-05  |  2KB  |  86 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://SmallEiffel.loria.fr
  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_null 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.       local
  56.          bool: BOOLEAN;
  57.       do
  58.          if bool then
  59.             put_byte(byte)
  60.          else
  61.             c_inline_c("fputc(a1,C->_output_stream);");
  62.          end;
  63.       end;
  64.  
  65.    disconnect is
  66.       require
  67.          is_connected
  68.       do
  69.          fclose(output_stream);
  70.          path := Void;
  71.       end;
  72.  
  73. feature {NONE}
  74.  
  75.    fclose(stream_pointer : POINTER) is
  76.       external "C_InlineWithoutCurrent"
  77.       end;
  78.  
  79.    bfw_open(path_count: INTEGER; path_pointer: POINTER): POINTER is
  80.       do
  81.          c_inline_c("R=fopen(a2,%"wb%");");
  82.       end;
  83.  
  84. end -- BINARY_FILE_WRITE
  85.  
  86.