home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / eiffel / smalleif.97 / se.t / SmallEiffel / lib_std / std_file.e < prev    next >
Encoding:
Text File  |  1996-05-02  |  1.9 KB  |  75 lines

  1. -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C) 
  2. -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
  3. --
  4. deferred class STD_FILE
  5. --
  6. -- Root class of : 
  7. --   - STD_INPUT to read on the keyboard (known as `std_input').
  8. --   - STD_OUTPUT to write on the screen (known as `std_output').
  9. --   - STD_INPUT_OUTPUT to read/write on the keyboard/screen (known as `io').
  10. --   - STD_FILE_READ to read a named file on disk. 
  11. --   - STD_FILE_WRITE to write a named file on disk.
  12. --   - CURSES interactive screen/cursor handling.
  13. --   - STD_ERROR to write on the error file (default is screen).
  14. --
  15. -- Note : a common list of feature (such as `put_character',  
  16. --        `put_string', etc.) are shared by all classes so you can 
  17. --        exchanges objects.
  18. --        For example, it easy to test writing on the screen (using 
  19. --        `std_output') and then to use a named file (using 
  20. --        STD_FILE_WRITE or `connect_to').
  21. --
  22.  
  23. feature {ANY}
  24.    
  25.    path: STRING;
  26.      -- Not Void when connected to the corresponding file on the disk.
  27.    
  28.    connect_to(new_path: STRING) is
  29.       require
  30.      not is_connected;
  31.      path = Void;
  32.      not new_path.empty;
  33.       deferred
  34.       end;
  35.    
  36.    disconnect is
  37.       require
  38.      is_connected;
  39.      path /= Void;
  40.       deferred
  41.       end;
  42.    
  43.    is_connected: BOOLEAN is
  44.       do
  45.      Result := path /= Void;
  46.       end;
  47.    
  48. feature {NONE}
  49.    --
  50.    -- NOTE: use only a few basic ANSI C functions.
  51.    -- Try to use a as less as possible external C calls.
  52.    --
  53.    
  54.    mode: STRING; 
  55.  
  56.    fopen(f: STRING; m: STRING): POINTER is
  57.       require
  58.      f /= Void;
  59.      m /= Void
  60.       do
  61.      f.extend('%U');
  62.      m.extend('%U');
  63.      c_inline_c("R=(T0 *)fopen(((Tstring *)a1)->_storage,%
  64.              %((Tstring *)a2)->_storage);");
  65.      f.remove_last(1);
  66.      m.remove_last(1);
  67.       end;
  68.    
  69.    fclose (stream_pointer : POINTER): INTEGER is
  70.       external "C"
  71.       alias "fclose"
  72.       end;
  73.    
  74. end -- STD_FILE
  75.