home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_std / std_file_write.e < prev    next >
Text File  |  1999-06-05  |  2KB  |  96 lines

  1. -- This file is  free  software, which  comes  along  with  SmallEiffel. This
  2. -- software  is  distributed  in the hope that it will be useful, but WITHOUT 
  3. -- ANY  WARRANTY;  without  even  the  implied warranty of MERCHANTABILITY or
  4. -- FITNESS  FOR A PARTICULAR PURPOSE. You can modify it as you want, provided
  5. -- this header is kept unaltered, and a notification of the changes is added.
  6. -- You  are  allowed  to  redistribute  it and sell it, alone or as a part of 
  7. -- another product.
  8. --          Copyright (C) 1994-98 LORIA - UHP - CRIN - INRIA - FRANCE
  9. --            Dominique COLNET and Suzanne COLLIN - colnet@loria.fr 
  10. --                       http://SmallEiffel.loria.fr
  11. --
  12. class STD_FILE_WRITE
  13. --
  14. -- Basic output facilities to write a named file on the disk.
  15. --
  16. -- Note : most features are common with STD_OUTPUT so you can 
  17. --        test your program first on the screen and then, changing 
  18. --        of instance (STD_OUTPUT/STD_FILE_WRITE), doing the same
  19. --        on a file.
  20. --
  21.    
  22. inherit OUTPUT_STREAM
  23.    
  24. creation 
  25.    connect_to, make
  26.  
  27. feature
  28.    
  29.    path: STRING;
  30.          -- Not Void when connected to the corresponding file
  31.          -- on the disk.
  32.  
  33. feature {NONE}
  34.    
  35.    output_stream: POINTER;
  36.  
  37. feature 
  38.  
  39.    connect_to(new_path: STRING) is
  40.       require
  41.          not is_connected;
  42.          not new_path.empty
  43.       local
  44.          p: POINTER;
  45.       do
  46.          p := new_path.to_external;
  47.          output_stream := sfw_open(p);
  48.          if output_stream.is_not_null then
  49.             path := new_path;
  50.          end;
  51.       end;
  52.    
  53. feature
  54.  
  55.    disconnect is
  56.       require
  57.          is_connected
  58.       do
  59.          fclose(output_stream); 
  60.          path := Void;
  61.       end;
  62.    
  63.    make is
  64.       do
  65.       end;
  66.  
  67. feature
  68.  
  69.    is_connected: BOOLEAN is
  70.       do
  71.          Result := path /= Void;
  72.       end;
  73.  
  74.    flush is
  75.       do
  76.          flush_stream(output_stream);
  77.       end;
  78.  
  79.    put_character(c: CHARACTER) is
  80.       do
  81.          write_byte(output_stream,c);
  82.       end;
  83.  
  84. feature {NONE}
  85.    
  86.    sfw_open(path_pointer: POINTER): POINTER is
  87.       external "SmallEiffel"
  88.       end;
  89.  
  90.    fclose(stream_pointer : POINTER) is
  91.       external "C_InlineWithoutCurrent"
  92.       end;
  93.  
  94. end -- STD_FILE_WRITE
  95.  
  96.