Automatic generation produced by ISE Eiffel

Classes Clusters Cluster hierarchy Chart Relations Text Flat Contracts Flat contracts Go to:
indexing description: "[ Commonly used console input and output mechanisms. This class may be used as ancestor by classes needing its facilities. ]" status: "See notice at end of class" date: "$Date: 2001-11-16 20:32:23 +0000 (Fri, 16 Nov 2001) $" revision: "$Revision: 51435 $" class CONSOLE create {STD_FILES} make_open_stdin, make_open_stdout, make_open_stderr feature -- Initialization make_open_stderr (fn: STRING) is -- Create an unix standard error file. do make (fn) file_pointer := console_def (2) set_write_mode end make_open_stdin (fn: STRING) is -- Create an unix standard input file. require -- from FILE string_exists: fn /= void string_not_empty: not fn.is_empty do make (fn) file_pointer := console_def (0) set_read_mode create last_string.make (256) ensure -- from FILE exists: exists open_read: is_open_read end make_open_stdout (fn: STRING) is -- Create an unix standard output file. require -- from FILE string_exists: fn /= void string_not_empty: not fn.is_empty do make (fn) file_pointer := console_def (1) set_write_mode ensure -- from FILE exists: exists open_write: is_open_write end feature {NONE} -- Initialization make (fn: STRING) is -- Create file object with fn as file name. -- (from FILE) require -- from FILE string_exists: fn /= void string_not_empty: not fn.is_empty do name := fn mode := closed_file create last_string.make (256) ensure -- from FILE file_named: name.is_equal (fn) file_closed: is_closed end make_create_read_write (fn: STRING) is -- Create file object with fn as file name -- and open file for both reading and writing; -- create it if it does not exist. -- (from FILE) require -- from FILE string_exists: fn /= void string_not_empty: not fn.is_empty do make (fn) create_read_write ensure -- from FILE exists: exists open_read: is_open_read open_write: is_open_write end make_open_append (fn: STRING) is -- Create file object with fn as file name -- and open file in append-only mode. -- (from FILE) require -- from FILE string_exists: fn /= void string_not_empty: not fn.is_empty do make (fn) open_append ensure -- from FILE exists: exists open_append: is_open_append end make_open_read_append (fn: STRING) is -- Create file object with fn as file name -- and open file for reading anywhere -- but writing at the end only. -- Create file if it does not exist. -- (from FILE) require -- from FILE string_exists: fn /= void string_not_empty: not fn.is_empty do make (fn) open_read_append ensure -- from FILE exists: exists open_read: is_open_read open_append: is_open_append end make_open_read_write (fn: STRING) is -- Create file object with fn as file name -- and open file for both reading and writing. -- (from FILE) require -- from FILE string_exists: fn /= void string_not_empty: not fn.is_empty do make (fn) open_read_write ensure -- from FILE exists: exists open_read: is_open_read open_write: is_open_write end feature {NONE} -- Access access_date: INTEGER is -- Time stamp of last access made to the inode. -- (from FILE) require -- from FILE file_exists: exists do set_buffer Result := buffered_file_info.access_date end C_memory: INTEGER is 2 -- Code for the C memory managed -- by the garbage collector -- (from MEM_CONST) date: INTEGER is -- Time stamp (time of last modification) -- (from FILE) require -- from FILE file_exists: exists do set_buffer Result := buffered_file_info.date end descriptor: INTEGER is -- File descriptor as used by the operating system. -- (from FILE) require -- from IO_MEDIUM valid_handle: descriptor_available require else -- from FILE file_opened: not is_closed do Result := file_fd (file_pointer) descriptor_available := True end descriptor_available: BOOLEAN -- (from FILE) Eiffel_memory: INTEGER is 1 -- Code for the Eiffel memory managed -- by the garbage collector -- (from MEM_CONST) file_info: UNIX_FILE_INFO is -- Collected information about the file. -- (from FILE) do set_buffer Result := clone (buffered_file_info) end Full_collector: INTEGER is 0 -- Statistics for full collections -- (from MEM_CONST) group_id: INTEGER is -- Group identification of owner -- (from FILE) require -- from FILE file_exists: exists do set_buffer Result := buffered_file_info.group_id end has (v: like item): BOOLEAN is -- Does structure include an occurrence of v? -- (Reference or object equality, -- based on object_comparison.) -- (from LINEAR) do start if not off then search (v) end Result := not exhausted ensure -- from CONTAINER not_found_in_empty: Result implies not is_empty end Incremental_collector: INTEGER is 1 -- Statistics for incremental collections -- (from MEM_CONST) index_of (v: like item; i: INTEGER): INTEGER is -- Index of i-th occurrence of v. -- 0 if none. -- (Reference or object equality, -- based on object_comparison.) -- (from LINEAR) require -- from LINEAR positive_occurrences: i > 0 local occur, pos: INTEGER do if object_comparison and v /= void then from start pos := 1 until off or (occur = i) loop if item /= void and then v.is_equal (item) then occur := occur + 1 end forth pos := pos + 1 end else from start pos := 1 until off or (occur = i) loop if item = v then occur := occur + 1 end forth pos := pos + 1 end end if occur = i then Result := pos - 1 end ensure -- from LINEAR non_negative_result: Result >= 0 end inode: INTEGER is -- I-node number -- (from FILE) require -- from FILE file_exists: exists do set_buffer Result := buffered_file_info.inode end item: CHARACTER is -- Current item -- (from FILE) require -- from TRAVERSABLE not_off: not off require -- from ACTIVE readable: readable do read_character Result := last_character back end links: INTEGER is -- Number of links on file -- (from FILE) require -- from FILE file_exists: exists do set_buffer Result := buffered_file_info.links end name: STRING -- File name -- (from FILE) occurrences (v: CHARACTER): INTEGER is -- Number of times v appears. -- (Reference or object equality, -- based on object_comparison.) -- (from LINEAR) do from start search (v) until exhausted loop Result := Result + 1 forth search (v) end ensure -- from BAG non_negative_occurrences: Result >= 0 end owner_name: STRING is -- Name of owner -- (from FILE) require -- from FILE file_exists: exists do set_buffer Result := buffered_file_info.owner_name end position: INTEGER is -- Current cursor position. -- (from FILE) do if not is_closed then Result := file_tell (file_pointer) end end protection: INTEGER is -- Protection mode, in decimal value -- (from FILE) require -- from FILE file_exists: exists do set_buffer Result := buffered_file_info.protection end retrieved: ANY is -- Retrieved object structure -- To access resulting object under correct type, -- use assignment attempt. -- Will raise an exception (code Retrieve_exception) -- if content is not a stored Eiffel structure. -- (from FILE) require -- from IO_MEDIUM exists: exists is_open_read: is_open_read support_storable: support_storable do Result := c_retrieved (descriptor) ensure -- from IO_MEDIUM result_exists: Result /= void end sequential_search (v: like item) is -- Move to first position (at or after current -- position) where item and v are equal. -- (Reference or object equality, -- based on object_comparison.) -- If no such position ensure that exhausted will be true. -- (from LINEAR) do if object_comparison and v /= void then from until exhausted or else (item /= void and then v.is_equal (item)) loop forth end else from until exhausted or else v = item loop forth end end ensure -- from LINEAR object_found: (not exhausted and object_comparison) implies equal (v, item) item_found: (not exhausted and not object_comparison) implies v = item end Total_memory: INTEGER is 0 -- Code for all the memory managed -- by the garbage collector -- (from MEM_CONST) user_id: INTEGER is -- User identification of owner -- (from FILE) require -- from FILE file_exists: exists do set_buffer Result := buffered_file_info.user_id end feature -- Access file_pointer: POINTER -- File pointer as required in C -- (from FILE) separator: CHARACTER -- ASCII code of character following last word read -- (from FILE) feature {NONE} -- Measurement gc_statistics (collector_type: INTEGER): GC_INFO is -- Garbage collection information for collector_type. -- (from MEMORY) require -- from MEMORY type_ok: collector_type = full_collector or collector_type = incremental_collector do create Result.make (collector_type) end memory_statistics (memory_type: INTEGER): MEM_INFO is -- Memory usage information for memory_type -- (from MEMORY) require -- from MEMORY type_ok: memory_type = total_memory or memory_type = eiffel_memory or memory_type = c_memory do create Result.make (memory_type) end feature -- Status report end_of_file: BOOLEAN is -- Have we reached the end of file? require -- from FILE opened: not is_closed do Result := console_eof (file_pointer) end exists: BOOLEAN is -- Does file exist? do Result := True ensure then -- from FILE unchanged_mode: mode = old mode end feature {NONE} -- Status report access_exists: BOOLEAN is -- Does physical file exist? -- (Uses real UID.) -- (from FILE) local external_name: ANY do external_name := name.to_c Result := file_access ($external_name, 0) end after: BOOLEAN is -- Is there no valid cursor position to the right of cursor position? -- (from FILE) do Result := not is_closed and then (end_of_file or count = 0) end before: BOOLEAN is -- Is there no valid cursor position to the left of cursor position? -- (from FILE) do Result := is_closed end changeable_comparison_criterion: BOOLEAN is -- May object_comparison be changed? -- (Answer: yes by default.) -- (from CONTAINER) do Result := True end chunk_size: INTEGER is -- Minimal size of a memory chunk. The run-time always -- allocates a multiple of this size. -- If the environment variable EIF_MEMORY_CHUNK -- is defined, it is set to the closest reasonable -- value from it. -- (from MEMORY) external "C | %"eif_memory.h%"" alias "eif_get_chunk_size" end coalesce_period: INTEGER is -- Period of full coalesce (in number of collections) -- If the environment variable EIF_FULL_COALESCE_PERIOD -- is defined, it is set to the closest reasonable -- value from it. -- If null, no full coalescing is launched. -- (from MEMORY) external "C | %"eif_memory.h%"" alias "eif_coalesce_period" end collecting: BOOLEAN is -- Is garbage collection enabled? -- (from MEMORY) external "C | %"eif_memory.h%"" alias "gc_ison" end collection_period: INTEGER is -- Period of full collection. -- If the environment variable EIF_FULL_COLLECTION_PERIOD -- is defined, it is set to the closest reasonable -- value from it. -- If null, no full collection is launched. -- (from MEMORY) external "C | %"eif_memory.h%"" alias "mem_pget" end empty: BOOLEAN is obsolete "ELKS 2000: Use `is_empty' instead" -- Is there no element? -- (from CONTAINER) do Result := is_empty end exhausted: BOOLEAN is -- Has structure been completely explored? -- (from LINEAR) do Result := off ensure -- from LINEAR exhausted_when_off: off implies Result end extendible: BOOLEAN is -- May new items be added? -- (from FILE) do Result := mode >= write_file end file_prunable: BOOLEAN is -- May items be removed? -- (from FILE) do Result := mode >= write_file and prunable end file_writable: BOOLEAN is -- Is there a current item that may be modified? -- (from FILE) do Result := mode >= write_file end Full: BOOLEAN is False -- Is structure filled to capacity? -- (from FILE) generation_object_limit: INTEGER is -- Maximum size of object in generational scavenge zone. -- If the environment variable EIF_GS_LIMIT -- is defined, it is set to the closest reasonable -- value from it. -- (from MEMORY) external "C | %"eif_memory.h%"" alias "eif_generation_object_limit" end is_access_executable: BOOLEAN is -- Is file executable by real UID? -- (from FILE) require -- from FILE file_exists: exists do set_buffer Result := buffered_file_info.is_access_executable end is_access_owner: BOOLEAN is -- Is file owned by real UID? -- (from FILE) require -- from FILE file_exists: exists do set_buffer Result := buffered_file_info.is_access_owner end is_access_readable: BOOLEAN is -- Is file readable by real UID? -- (from FILE) require -- from FILE file_exists: exists do set_buffer Result := buffered_file_info.is_access_readable end is_access_writable: BOOLEAN is -- Is file writable by real UID? -- (from FILE) require -- from FILE file_exists: exists do set_buffer Result := buffered_file_info.is_access_writable end is_block: BOOLEAN is -- Is file a block special file? -- (from FILE) require -- from FILE file_exists: exists do set_buffer Result := buffered_file_info.is_block end is_character: BOOLEAN is -- Is file a character special file? -- (from FILE) require -- from FILE file_exists: exists do set_buffer Result := buffered_file_info.is_character end is_closed: BOOLEAN is -- Is file closed? -- (from FILE) do Result := mode = closed_file end is_creatable: BOOLEAN is -- Is file creatable in parent directory? -- (Uses effective UID to check that parent is writable -- and file does not exist.) -- (from FILE) local external_name: ANY do external_name := name.to_c Result := file_creatable ($external_name) end is_device: BOOLEAN is -- Is file a device? -- (from FILE) require -- from FILE file_exists: exists do set_buffer Result := buffered_file_info.is_device end is_directory: BOOLEAN is -- Is file a directory? -- (from FILE) require -- from FILE file_exists: exists do set_buffer Result := buffered_file_info.is_directory end is_executable: BOOLEAN is -- Is file executable? -- (Checks execute permission for effective UID.) -- (from FILE) require -- from IO_MEDIUM handle_exists: exists do set_buffer Result := buffered_file_info.is_executable end is_fifo: BOOLEAN is -- Is file a named pipe? -- (from FILE) require -- from FILE file_exists: exists do set_buffer Result := buffered_file_info.is_fifo end is_inserted (v: CHARACTER): BOOLEAN is -- Has v been inserted by the most recent insertion? -- (By default, the value returned is equivalent to calling -- `has (v)'. However, descendants might be able to provide more -- efficient implementations.) -- (from COLLECTION) do Result := has (v) end is_open_append: BOOLEAN is -- Is file open for appending? -- (from FILE) do Result := mode = append_file or else mode = append_read_file end is_open_read: BOOLEAN is -- Is file open for reading? -- (from FILE) do Result := mode = read_file or else mode = read_write_file or else mode = append_read_file end is_open_write: BOOLEAN is -- Is file open for writing? -- (from FILE) do Result := mode = write_file or else mode = read_write_file or else mode = append_read_file or else mode = append_file end is_owner: BOOLEAN is -- Is file owned by effective UID? -- (from FILE) require -- from FILE file_exists: exists do set_buffer Result := buffered_file_info.is_owner end is_plain: BOOLEAN is -- Is file a plain file? -- (from FILE) require -- from FILE file_exists: exists do set_buffer Result := buffered_file_info.is_plain end is_plain_text: BOOLEAN is -- Is file reserved for text (character sequences)? (Yes) -- (from PLAIN_TEXT_FILE) do Result := True end is_readable: BOOLEAN is -- Is file readable? -- (Checks permission for effective UID.) -- (from FILE) require -- from IO_MEDIUM handle_exists: exists do set_buffer Result := buffered_file_info.is_readable end is_setgid: BOOLEAN is -- Is file setgid? -- (from FILE) require -- from FILE file_exists: exists do set_buffer Result := buffered_file_info.is_setgid end is_setuid: BOOLEAN is -- Is file setuid? -- (from FILE) require -- from FILE file_exists: exists do set_buffer Result := buffered_file_info.is_setuid end is_socket: BOOLEAN is -- Is file a named socket? -- (from FILE) require -- from FILE file_exists: exists do set_buffer Result := buffered_file_info.is_socket end is_sticky: BOOLEAN is -- Is file sticky (for memory swaps)? -- (from FILE) require -- from FILE file_exists: exists do set_buffer Result := buffered_file_info.is_sticky end is_symlink: BOOLEAN is -- Is file a symbolic link? -- (from FILE) require -- from FILE file_exists: exists do set_buffer Result := buffered_file_info.is_symlink end is_writable: BOOLEAN is -- Is file writable? -- (Checks write permission for effective UID.) -- (from FILE) require -- from IO_MEDIUM handle_exists: exists do set_buffer Result := buffered_file_info.is_writable end largest_coalesced_block: INTEGER is -- Size of largest coalesced block since last call to -- largest_coalesced; 0 if none. -- (from MEMORY) external "C | %"eif_memory.h%"" alias "mem_largest" end max_mem: INTEGER is -- Maximum amount of bytes the run-time can allocate. -- (from MEMORY) external "C | %"eif_memory.h%"" alias "eif_get_max_mem" end memory_threshold: INTEGER is -- Minimum amount of bytes to be allocated before -- starting an automatic garbage collection. -- (from MEMORY) external "C | %"eif_memory.h%"" alias "mem_tget" end object_comparison: BOOLEAN -- Must search operations use equal rather than = -- for comparing references? (Default: no, use =.) -- (from CONTAINER) off: BOOLEAN is -- Is there no item? -- (from FILE) do Result := (count = 0) or else is_closed or else end_of_file end readable: BOOLEAN is -- Is there a current item that may be read? -- (from SEQUENCE) require -- from ACTIVE True require -- from IO_MEDIUM handle_exists: exists do Result := not off end referers (an_object: ANY): ARRAY [ANY] is -- Objects that refer to an_object. -- (from MEMORY) local a: ANY do create Result.make (0, 200) a := Result.area find_referers ($an_object, $a, Result.count) end scavenge_zone_size: INTEGER is -- Size of generational scavenge zone. -- If the environment variable EIF_MEMORY_SCAVENGE -- is defined, it is set to the closest reasonable -- value from it. -- (from MEMORY) external "C | %"eif_memory.h%"" alias "eif_scavenge_zone_size" end Support_storable: BOOLEAN is False -- Can medium be used to store an Eiffel structure? -- (from PLAIN_TEXT_FILE) tenure: INTEGER is -- Maximum age of object before being considered -- as old (old objects are not scanned during -- partial collection). -- If the environment variable EIF_TENURE_MAX -- is defined, it is set to the closest reasonable -- value from it. -- (from MEMORY) external "C | %"eif_memory.h%"" alias "eif_tenure" end writable: BOOLEAN is -- Is there a current item that may be modified? -- (from SEQUENCE) do Result := not off end feature -- Status report file_readable: BOOLEAN is -- Is there a current item that may be read? -- (from FILE) do Result := (mode >= read_write_file or mode = read_file) and readable end last_character: CHARACTER -- Last character read by read_character -- (from IO_MEDIUM) last_double: DOUBLE -- Last double read by read_double -- (from IO_MEDIUM) last_integer: INTEGER -- Last integer read by read_integer -- (from IO_MEDIUM) last_real: REAL -- Last real read by read_real -- (from IO_MEDIUM) last_string: STRING -- Last string read -- (from IO_MEDIUM) feature {NONE} -- Status setting allocate_compact is -- Enter `memory' mode: will try to compact memory -- before requesting more from the operating system. -- (from MEMORY) external "C | %"eif_memory.h%"" alias "mem_slow" end allocate_fast is -- Enter `speed' mode: will optimize speed of memory -- allocation rather than memory usage. -- (from MEMORY) external "C | %"eif_memory.h%"" alias "mem_speed" end allocate_tiny is -- Enter `tiny' mode: will enter `memory' mode -- after having freed as much memory as possible. -- (from MEMORY) external "C | %"eif_memory.h%"" alias "mem_tiny" end close is -- Close file. -- (from FILE) require -- from IO_MEDIUM medium_is_open: not is_closed do file_close (file_pointer) mode := closed_file descriptor_available := False ensure then -- from FILE is_closed: is_closed end collection_off is -- Disable garbage collection. -- (from MEMORY) external "C | %"eif_garcol.h%"" alias "gc_stop" end collection_on is -- Enable garbage collection. -- (from MEMORY) external "C | %"eif_garcol.h%"" alias "gc_run" end compare_objects is -- Ensure that future search operations will use equal -- rather than = for comparing references. -- (from CONTAINER) require -- from CONTAINER changeable_comparison_criterion do object_comparison := True ensure -- from CONTAINER object_comparison end compare_references is -- Ensure that future search operations will use = -- rather than equal for comparing references. -- (from CONTAINER) require -- from CONTAINER changeable_comparison_criterion do object_comparison := False ensure -- from CONTAINER reference_comparison: not object_comparison end create_read_write is -- Open file in read and write mode; -- create it if it does not exist. -- (from FILE) require -- from FILE is_closed: is_closed local external_name: ANY do external_name := name.to_c file_pointer := file_open ($external_name, 4) mode := read_write_file ensure -- from FILE exists: exists open_read: is_open_read open_write: is_open_write end disable_time_accounting is -- Disable GC time accounting (default). -- (from MEMORY) do gc_monitoring (False) end enable_time_accounting is -- Enable GC time accouting, accessible in gc_statistics. -- (from MEMORY) do gc_monitoring (True) end fd_open_append (fd: INTEGER) is -- Open file of descriptor fd in append mode. -- (from FILE) do file_pointer := file_dopen (fd, 2) mode := append_file ensure -- from FILE exists: exists open_append: is_open_append end fd_open_read (fd: INTEGER) is -- Open file of descriptor fd in read-only mode. -- (from FILE) do file_pointer := file_dopen (fd, 0) mode := read_file ensure -- from FILE exists: exists open_read: is_open_read end fd_open_read_append (fd: INTEGER) is -- Open file of descriptor fd -- in read and write-at-end mode. -- (from FILE) local external_name: ANY do external_name := name.to_c file_pointer := file_dopen (fd, 5) mode := append_read_file ensure -- from FILE exists: exists open_read: is_open_read open_append: is_open_append end fd_open_read_write (fd: INTEGER) is -- Open file of descriptor fd in read-write mode. -- (from FILE) do file_pointer := file_dopen (fd, 3) mode := read_write_file ensure -- from FILE exists: exists open_read: is_open_read open_write: is_open_write end fd_open_write (fd: INTEGER) is -- Open file of descriptor fd in write mode. -- (from FILE) do file_pointer := file_dopen (fd, 1) mode := write_file ensure -- from FILE exists: exists open_write: is_open_write end open_append is -- Open file in append-only mode; -- create it if it does not exist. -- (from FILE) require -- from FILE is_closed: is_closed local external_name: ANY do external_name := name.to_c file_pointer := file_open ($external_name, 2) mode := append_file ensure -- from FILE exists: exists open_append: is_open_append end open_read is -- Open file in read-only mode. -- (from FILE) require -- from FILE is_closed: is_closed local external_name: ANY do external_name := name.to_c file_pointer := file_open ($external_name, 0) mode := read_file ensure -- from FILE exists: exists open_read: is_open_read end open_read_append is -- Open file in read and write-at-end mode; -- create it if it does not exist. -- (from FILE) require -- from FILE is_closed: is_closed local external_name: ANY do external_name := name.to_c file_pointer := file_open ($external_name, 5) mode := append_read_file ensure -- from FILE exists: exists open_read: is_open_read open_append: is_open_append end open_read_write is -- Open file in read and write mode. -- (from FILE) require -- from FILE is_closed: is_closed local external_name: ANY do external_name := name.to_c file_pointer := file_open ($external_name, 3) mode := read_write_file ensure -- from FILE exists: exists open_read: is_open_read open_write: is_open_write end open_write is -- Open file in write-only mode; -- create it if it does not exist. -- (from FILE) local external_name: ANY do external_name := name.to_c file_pointer := file_open ($external_name, 1) mode := write_file ensure -- from FILE exists: exists open_write: is_open_write end recreate_read_write (fname: STRING) is -- Reopen in read-write mode with file of name fname; -- create file if it does not exist. -- (from FILE) require -- from FILE is_open: not is_closed valid_name: fname /= void local external_name: ANY do external_name := name.to_c file_pointer := file_reopen ($external_name, 4, file_pointer) name := fname mode := read_write_file ensure -- from FILE exists: exists open_read: is_open_read open_write: is_open_write end reopen_append (fname: STRING) is -- Reopen in append mode with file of name fname; -- create file if it does not exist. -- (from FILE) require -- from FILE is_open: not is_closed valid_name: fname /= void local external_name: ANY do external_name := name.to_c file_pointer := file_reopen ($external_name, 2, file_pointer) name := fname mode := append_file ensure -- from FILE exists: exists open_append: is_open_append end reopen_read (fname: STRING) is -- Reopen in read-only mode with file of name fname; -- create file if it does not exist. -- (from FILE) require -- from FILE is_open: not is_closed valid_name: fname /= void local external_name: ANY do external_name := fname.to_c file_pointer := file_reopen ($external_name, 0, file_pointer) name := fname mode := read_file ensure -- from FILE exists: exists open_read: is_open_read end reopen_read_append (fname: STRING) is -- Reopen in read and write-at-end mode with file -- of name fname; create file if it does not exist. -- (from FILE) require -- from FILE is_open: not is_closed valid_name: fname /= void local external_name: ANY do external_name := name.to_c file_pointer := file_reopen ($external_name, 5, file_pointer) name := fname mode := append_read_file ensure -- from FILE exists: exists open_read: is_open_read open_append: is_open_append end reopen_read_write (fname: STRING) is -- Reopen in read-write mode with file of name fname. -- (from FILE) require -- from FILE is_open: not is_closed valid_name: fname /= void local external_name: ANY do external_name := name.to_c file_pointer := file_reopen ($external_name, 3, file_pointer) name := fname mode := read_write_file ensure -- from FILE exists: exists open_read: is_open_read open_write: is_open_write end reopen_write (fname: STRING) is -- Reopen in write-only mode with file of name fname; -- create file if it does not exist. -- (from FILE) require -- from FILE is_open: not is_closed valid_name: fname /= void local external_name: ANY do external_name := name.to_c file_pointer := file_reopen ($external_name, 1, file_pointer) name := fname mode := write_file ensure -- from FILE exists: exists open_write: is_open_write end set_coalesce_period (value: INTEGER) is -- Set coalesce_period. Every value collection, -- the Garbage Collector will coalesce -- the whole memory. -- (from MEMORY) require -- from MEMORY positive_value: value >= 0 external "C | %"eif_memory.h%"" alias "eif_set_coalesce_period" end set_collection_period (value: INTEGER) is -- Set collection_period. Every value collection, -- the Garbage collector will perform a collection -- on the whole memory (full collection), otherwise -- a simple partial collection is done. -- (from MEMORY) require -- from MEMORY positive_value: value >= 0 external "C | %"eif_memory.h%"" alias "mem_pset" end set_max_mem (value: INTEGER) is -- Set the maximum amount of memory the run-time can allocate. -- (from MEMORY) require -- from MEMORY positive_value: value > 0 external "C | %"eif_memory.h%"" alias "eif_set_max_mem" end set_memory_threshold (value: INTEGER) is -- Set a new memory_threshold in bytes. Whenever the memory -- allocated for Eiffel reaches this value, an automatic -- collection is performed. -- (from MEMORY) require -- from MEMORY positive_value: value > 0 external "C | %"eif_memory.h%"" alias "mem_tset" end feature {NONE} -- Cursor movement back is -- Go back one position. -- (from FILE) require -- from BILINEAR not_before: not before do file_move (file_pointer, - 1) end finish is -- Go to last position. -- (from FILE) require -- from LINEAR True require else -- from FILE file_opened: not is_closed do file_recede (file_pointer, 0) end forth is -- Go to next position. -- (from FILE) require -- from LINEAR not_after: not after require else -- from FILE file_opened: not is_closed do file_move (file_pointer, 1) end go (abs_position: INTEGER) is -- Go to the absolute position. -- (New position may be beyond physical length.) -- (from FILE) require -- from FILE file_opened: not is_closed non_negative_argument: abs_position >= 0 do file_go (file_pointer, abs_position) end move (offset: INTEGER) is -- Advance by offset from current location. -- (from FILE) require -- from FILE file_opened: not is_closed do file_move (file_pointer, offset) end recede (abs_position: INTEGER) is -- Go to the absolute position backwards, -- starting from end of file. -- (from FILE) require -- from FILE file_opened: not is_closed non_negative_argument: abs_position >= 0 do file_recede (file_pointer, abs_position) end search (v: like item) is -- Move to first position (at or after current -- position) where item and v are equal. -- If structure does not include v ensure that -- exhausted will be true. -- (Reference or object equality, -- based on object_comparison.) -- (from BILINEAR) do if before and not is_empty then forth end sequential_search (v) ensure -- from LINEAR object_found: (not exhausted and object_comparison) implies equal (v, item) item_found: (not exhausted and not object_comparison) implies v = item end start is -- Go to first position. -- (from FILE) require -- from TRAVERSABLE True require else -- from FILE file_opened: not is_closed do file_go (file_pointer, 0) end feature {NONE} -- Element change add_permission (who, what: STRING) is -- Add read, write, execute or setuid permission -- for who ('u', 'g' or 'o') to what. -- (from FILE) require -- from FILE who_is_not_void: who /= void what_is_not_void: what /= void file_descriptor_exists: exists local external_name, ext_who, ext_what: ANY do external_name := name.to_c ext_who := who.to_c ext_what := what.to_c file_perm ($external_name, $ext_who, $ext_what, 1) end basic_store (object: ANY) is -- Produce an external representation of the -- entire object structure reachable from object. -- Retrievable within current system only. -- (from FILE) require -- from IO_MEDIUM object_not_void: object /= void exists: exists is_open_write: is_open_write support_storable: support_storable do c_basic_store (descriptor, $object) end change_date: INTEGER is -- Time stamp of last change. -- (from FILE) require -- from FILE file_exists: exists do set_buffer Result := buffered_file_info.change_date end change_group (new_group_id: INTEGER) is -- Change group of file to new_group_id found in -- system password file. -- (from FILE) require -- from FILE file_exists: exists local external_name: ANY do external_name := name.to_c file_chgrp ($external_name, new_group_id) end change_mode (mask: INTEGER) is -- Replace mode by mask. -- (from FILE) require -- from FILE file_exists: exists local external_name: ANY do external_name := name.to_c file_chmod ($external_name, mask) end change_name (new_name: STRING) is -- Change file name to new_name -- (from FILE) require -- from FILE new_name_not_void: new_name /= void file_exists: exists local ext_old_name, ext_new_name: ANY do ext_old_name := name.to_c ext_new_name := new_name.to_c file_rename ($ext_old_name, $ext_new_name) name := new_name ensure -- from FILE name_changed: name.is_equal (new_name) end change_owner (new_owner_id: INTEGER) is -- Change owner of file to new_owner_id found in -- system password file. On some systems this -- requires super-user privileges. -- (from FILE) require -- from FILE file_exists: exists local external_name: ANY do external_name := name.to_c file_chown ($external_name, new_owner_id) end extend (v: CHARACTER) is -- Include v at end. -- (from FILE) require -- from COLLECTION extendible: extendible do put_character (v) ensure -- from COLLECTION item_inserted: is_inserted (v) ensure then -- from BAG one_more_occurrence: occurrences (v) = old (occurrences (v)) + 1 end fill (other: CONTAINER [CHARACTER]) is -- Fill with as many items of other as possible. -- The representations of other and current structure -- need not be the same. -- (from COLLECTION) require -- from COLLECTION other_not_void: other /= void extendible local lin_rep: LINEAR [CHARACTER] do lin_rep := other.linear_representation from lin_rep.start until not extendible or else lin_rep.off loop extend (lin_rep.item) lin_rep.forth end end flush is -- Flush buffered data to disk. -- Note that there is no guarantee that the operating -- system will physically write the data to the disk. -- At least it will end up in the buffer cache, -- making the data visible to other processes. -- (from FILE) require -- from FILE is_open: not is_closed do file_flush (file_pointer) end force (v: like item) is -- Add v to end. -- (from SEQUENCE) require -- from SEQUENCE extendible: extendible do extend (v) ensure then -- from SEQUENCE new_count: count = old count + 1 item_inserted: has (v) end general_store (object: ANY) is -- Produce an external representation of the -- entire object structure reachable from object. -- Retrievable from other systems for same platform -- (machine architecture). -- (from FILE) require -- from IO_MEDIUM object_not_void: object /= void exists: exists is_open_write: is_open_write support_storable: support_storable do c_general_store (descriptor, $object) end independent_store (object: ANY) is -- Produce an external representation of the -- entire object structure reachable from object. -- Retrievable from other systems for the same or other -- platform (machine architecture). -- (from FILE) require -- from IO_MEDIUM object_not_void: object /= void exists: exists is_open_write: is_open_write support_storable: support_storable do c_independent_store (descriptor, $object) end link (fn: STRING) is -- Link current file to fn. -- fn must not already exist. -- (from FILE) require -- from FILE file_exists: exists local external_name: ANY fn_name: ANY do external_name := name.to_c fn_name := fn.to_c file_link ($external_name, $fn_name) end put (v: like item) is -- Add v to end. -- (from SEQUENCE) require -- from COLLECTION extendible: extendible do extend (v) ensure -- from COLLECTION item_inserted: is_inserted (v) ensure then -- from SEQUENCE new_count: count = old count + 1 end remove_permission (who, what: STRING) is -- Remove read, write, execute or setuid permission -- for who ('u', 'g' or 'o') to what. -- (from FILE) require -- from FILE who_is_not_void: who /= void what_is_not_void: what /= void file_descriptor_exists: exists local external_name, ext_who, ext_what: ANY do external_name := name.to_c ext_who := who.to_c ext_what := what.to_c file_perm ($external_name, $ext_who, $ext_what, 0) end set_access (time: INTEGER) is -- Stamp with time (access only). -- (from FILE) require -- from FILE file_exists: exists local external_name: ANY do external_name := name.to_c file_utime ($external_name, time, 0) ensure -- from FILE acess_date_updated: access_date = time date_unchanged: date = old date end set_date (time: INTEGER) is -- Stamp with time (modification time only). -- (from FILE) require -- from FILE file_exists: exists local external_name: ANY do external_name := name.to_c file_utime ($external_name, time, 1) ensure -- from FILE access_date_unchanged: access_date = old access_date date_updated: date = time end stamp (time: INTEGER) is -- Stamp with time (for both access and modification). -- (from FILE) require -- from FILE file_exists: exists local external_name: ANY do external_name := name.to_c file_utime ($external_name, time, 2) ensure -- from FILE date_updated: date = time end touch is -- Update time stamp (for both access and modification). -- (from FILE) require -- from FILE file_exists: exists local external_name: ANY do external_name := name.to_c file_touch ($external_name) ensure -- from FILE date_changed: date /= old date end feature -- Element change append (f: like Current) is -- Append a copy of the contents of f. -- (from FILE) require -- from SEQUENCE argument_not_void: s /= void require else -- from FILE target_is_closed: is_closed source_is_closed: f.is_closed do open_append f.open_read file_append (file_pointer, f.file_pointer, f.count) close f.close ensure -- from SEQUENCE new_count: count >= old count ensure then -- from FILE new_count: count = old count + f.count files_closed: f.is_closed and is_closed end feature -- Removal dispose is -- This is closed by the operating system at completion. do end feature {NONE} -- Removal collect is -- Force a partial collection cycle if garbage -- collection is enabled; do nothing otherwise. -- (from MEMORY) external "C | %"eif_eiffel.h%"" end delete is -- Remove link with physical file. -- File does not physically disappear from the disk -- until no more processes reference it. -- I/O operations on it are still possible. -- A directory must be empty to be deleted. -- (from FILE) require -- from FILE exists: exists local external_name: ANY do external_name := name.to_c file_unlink ($external_name) end free (object: ANY) is -- Free object, by-passing garbage collection. -- Erratic behavior will result if the object is still -- referenced. -- (from MEMORY) do mem_free ($object) end full_coalesce is -- Coalesce the whole memory: merge adjacent free -- blocks to reduce fragmentation. Useful, when -- a lot of memory is allocated with garbage collector off. -- (from MEMORY) external "C | %"eif_memory.h%"" alias "mem_coalesc" end full_collect is -- Force a full collection cycle if garbage -- collection is enabled; do nothing otherwise. -- (from MEMORY) external "C | %"eif_garcol.h%"" alias "plsc" end mem_free (addr: POINTER) is -- Free memory of object at addr. -- (Preferred interface is free.) -- (from MEMORY) external "C | %"eif_memory.h%"" end prune_all (v: like item) is -- Remove all occurrences of v; go off. -- (from SEQUENCE) require -- from COLLECTION prunable do from start until exhausted loop search (v) if not exhausted then remove end end ensure -- from COLLECTION no_more_occurrences: not has (v) end reset (fn: STRING) is -- Change file name to fn and reset -- file descriptor and all information. -- (from FILE) require -- from FILE valid_file_name: fn /= void do name := fn if mode /= closed_file then close end last_integer := 0 if last_string /= void then last_string.wipe_out end last_real := 0.0 last_character := '%U' last_double := 0.0 ensure -- from FILE file_renamed: name = fn file_closed: is_closed end wipe_out is -- Remove all items. -- (from FILE) require -- from COLLECTION prunable require else -- from FILE is_closed: is_closed do open_write close ensure -- from COLLECTION wiped_out: is_empty end feature {NONE} -- Conversion linear_representation: LINEAR [CHARACTER] is -- Representation as a linear structure -- (from LINEAR) do Result := Current end feature -- Obsolete lastchar: CHARACTER is -- Last character read by read_character -- (from IO_MEDIUM) do Result := last_character end lastdouble: DOUBLE is -- Last double read by read_double -- (from IO_MEDIUM) do Result := last_double end lastint: INTEGER is -- Last integer read by read_integer -- (from IO_MEDIUM) do Result := last_integer end lastreal: REAL is -- Last real read by read_real -- (from IO_MEDIUM) do Result := last_real end laststring: STRING is -- Last string read -- (from IO_MEDIUM) do Result := last_string end feature {NONE} -- Inapplicable Count: INTEGER is 1 -- Useless for CONSOLE class. go_to (r: CURSOR) is -- Move to position marked r. -- (from FILE) do end Is_empty: BOOLEAN is False -- Useless for CONSOLE class. prunable: BOOLEAN is -- Is there an item to be removed? -- (from FILE) do end prune (v: like item) is -- Remove an occurrence of v if any. -- (from FILE) require -- from COLLECTION prunable: prunable require else -- from FILE prunable: file_prunable do ensure then -- from FILE count <= old count end remove is -- Remove current item. -- (from FILE) require -- from ACTIVE prunable: prunable writable: writable require else -- from FILE file_prunable: file_prunable do end replace (v: like item) is -- Replace current item by v. -- (from FILE) require -- from ACTIVE writable: writable require else -- from FILE is_writable: file_writable do ensure -- from ACTIVE item_replaced: item = v ensure then -- from FILE item = v count = old count end feature {NONE} -- Implementation Append_file: INTEGER is 3 -- (from FILE) Append_read_file: INTEGER is 5 -- (from FILE) buffered_file_info: UNIX_FILE_INFO is -- Information about the file. -- (from FILE) once create Result.make end c_basic_store (file_handle: INTEGER; object: POINTER) is -- Store object structure reachable form current object -- in file pointer file_ptr. -- (from FILE) external "C | %"eif_store.h%"" alias "estore" end c_general_store (file_handle: INTEGER; object: POINTER) is -- Store object structure reachable form current object -- in file pointer file_ptr. -- (from FILE) external "C | %"eif_store.h%"" alias "eestore" end c_independent_store (file_handle: INTEGER; object: POINTER) is -- Store object structure reachable form current object -- in file pointer file_ptr. -- (from FILE) external "C | %"eif_store.h%"" alias "sstore" end c_retrieved (file_handle: INTEGER): ANY is -- Object structured retrieved from file of pointer -- file_ptr -- (from FILE) external "C | %"eif_retrieve.h%"" alias "eretrieve" end Closed_file: INTEGER is 0 -- (from FILE) console_def (number: INTEGER): POINTER is -- Convert number to the corresponding -- file descriptor. external "C | %"eif_console.h%"" end console_eof (file: POINTER): BOOLEAN is external "C (FILE *): EIF_BOOLEAN | %"eif_console.h%"" end console_next_line (file: POINTER) is -- Move to next input line on standard input. external "C (FILE *) | %"eif_console.h%"" end console_pc (file: POINTER; c: CHARACTER) is -- Write character c at end of file external "C (FILE *, EIF_CHARACTER) | %"eif_console.h%"" end console_pd (file: POINTER; d: DOUBLE) is -- Write double d at end of file external "C (FILE *, EIF_DOUBLE) | %"eif_console.h%"" end console_pi (file: POINTER; i: INTEGER) is -- Write integer i at end of file external "C (FILE *, EIF_INTEGER) | %"eif_console.h%"" end console_pr (file: POINTER; r: REAL) is -- Write real r at end of file external "C (FILE *, EIF_REAL) | %"eif_console.h%"" end console_ps (file: POINTER; s_name: POINTER; length: INTEGER) is -- Write string s at end of file external "C (FILE *, char *, EIF_INTEGER) | %"eif_console.h%"" end console_readchar (file: POINTER): CHARACTER is -- Read a character from the console external "C (FILE *): EIF_CHARACTER | %"eif_console.h%"" end console_readdouble (file: POINTER): DOUBLE is -- Read a double from the console external "C (FILE *): EIF_DOUBLE | %"eif_console.h%"" end console_readint (file: POINTER): INTEGER is -- Read an integer from the console external "C (FILE *): EIF_INTEGER | %"eif_console.h%"" end console_readline (file: POINTER; a_string: POINTER; length, begin: INTEGER): INTEGER is -- Read a stream from the console external "C (FILE *, char *, EIF_INTEGER, EIF_INTEGER): EIF_INTEGER | %"eif_console.h%"" end console_readreal (file: POINTER): REAL is -- Read a real number from the console external "C (FILE *): EIF_REAL | %"eif_console.h%"" end console_readstream (file: POINTER; a_string: POINTER; length: INTEGER): INTEGER is -- Read a stream from the console external "C (FILE *, char *, EIF_INTEGER): EIF_INTEGER | %"eif_console.h%"" end console_readword (file: POINTER; a_string: POINTER; length, begin: INTEGER): INTEGER is -- Read a string excluding white space and stripping -- leading white space from file into a_string. -- White space characters are: blank, new_line, -- tab, vertical tab, formfeed or end of file. -- If it does not fit, result is length - begin + 1, -- otherwise result is number of characters read. external "C (FILE *, char *, EIF_INTEGER, EIF_INTEGER): EIF_INTEGER | %"eif_console.h%"" end console_separator (file: POINTER): CHARACTER is -- ASCII code of character following last word read external "C (FILE *): EIF_CHARACTER | %"eif_console.h%"" end console_tnwl (file: POINTER) is -- Write a new_line to file external "C (FILE *) | %"eif_console.h%"" end false_string: STRING is -- Character string "false" -- (from FILE) once Result := "False" end file_access (f_name: POINTER; which: INTEGER): BOOLEAN is -- Perform access test which on f_name using real UID. -- (from FILE) external "C | %"eif_file.h%"" end file_append (file, from_file: POINTER; length: INTEGER) is -- Append a copy of from_file to file -- (from FILE) external "C (FILE *, FILE *, EIF_INTEGER) | %"eif_file.h%"" end file_chgrp (f_name: POINTER; new_group: INTEGER) is -- Change group of f_name to new_group -- (from FILE) external "C | %"eif_file.h%"" end file_chmod (f_name: POINTER; mask: INTEGER) is -- Change mode of f_name to mask. -- (from FILE) external "C | %"eif_file.h%"" end file_chown (f_name: POINTER; new_owner: INTEGER) is -- Change owner of f_name to new_owner -- (from FILE) external "C | %"eif_file.h%"" end file_close (file: POINTER) is -- Close file external "C (FILE *) | %"eif_console.h%"" alias "console_file_close" end file_creatable (f_name: POINTER): BOOLEAN is -- Is f_name creatable. -- (from FILE) external "C | %"eif_file.h%"" end file_dopen (fd, how: INTEGER): POINTER is -- File pointer for file of descriptor fd in mode how -- (which must fit the way fd was obtained). -- (from FILE) external "C | %"eif_file.h%"" end file_exists (f_name: POINTER): BOOLEAN is -- Does f_name exist. -- (from FILE) external "C | %"eif_file.h%"" end file_fd (file: POINTER): INTEGER is -- Operating system's file descriptor -- (from FILE) external "C (FILE *): EIF_INTEGER | %"eif_file.h%"" end file_feof (file: POINTER): BOOLEAN is -- End of file? -- (from FILE) external "C (FILE *): EIF_BOOLEAN | %"eif_file.h%"" end file_flush (file: POINTER) is -- Flush file. -- (from FILE) external "C (FILE *) | %"eif_file.h%"" end file_gc (file: POINTER): CHARACTER is -- Access the next character -- (from FILE) external "C (FILE *): EIF_CHARACTER | %"eif_file.h%"" end file_gd (file: POINTER): DOUBLE is -- Read a double from file -- (from PLAIN_TEXT_FILE) external "C (FILE *): EIF_DOUBLE | %"eif_file.h%"" end file_gi (file: POINTER): INTEGER is -- Get an integer from file -- (from PLAIN_TEXT_FILE) external "C (FILE *): EIF_INTEGER | %"eif_file.h%"" end file_go (file: POINTER; abs_position: INTEGER) is -- Go to absolute position, originated from start. -- (from FILE) external "C (FILE *, EIF_INTEGER) | %"eif_file.h%"" end file_gr (file: POINTER): REAL is -- Read a real from file -- (from PLAIN_TEXT_FILE) external "C (FILE *): EIF_REAL | %"eif_file.h%"" end file_gs (file: POINTER; a_string: POINTER; length, begin: INTEGER): INTEGER is -- a_string updated with characters read from file -- until new line, with begin characters already read. -- If it does not fit, result is length - begin + 1. -- If it fits, result is number of characters read. -- (from FILE) external "C (FILE *, char *, EIF_INTEGER, EIF_INTEGER): EIF_INTEGER | %"eif_file.h%"" end file_gss (file: POINTER; a_string: POINTER; length: INTEGER): INTEGER is -- Read min (length, remaining bytes in file) characters -- into a_string. If it does not fit, result is length + 1. -- Otherwise, result is the number of characters read. -- (from FILE) external "C (FILE *, char *, EIF_INTEGER): EIF_INTEGER | %"eif_file.h%"" end file_gw (file: POINTER; a_string: POINTER; length, begin: INTEGER): INTEGER is -- Read a string excluding white space and stripping -- leading white space from file into a_string. -- White space characters are: blank, new_line, -- tab, vertical tab, formfeed or end of file. -- If it does not fit, result is length - begin + 1, -- otherwise result is number of characters read. -- (from FILE) external "C (FILE *, char *, EIF_INTEGER, EIF_INTEGER): EIF_INTEGER | %"eif_file.h%"" end file_lh (file: POINTER): CHARACTER is -- Look ahead in file and find out the value of the next -- character. Do not read over character. -- (from FILE) external "C (FILE *): EIF_CHARACTER | %"eif_file.h%"" end file_link (from_name, to_name: POINTER) is -- Link to_name to from_name -- (from FILE) external "C (char *, char *) | %"eif_file.h%"" end file_move (file: POINTER; offset: INTEGER) is -- Move file pointer by offset. -- (from FILE) external "C (FILE *, EIF_INTEGER) | %"eif_file.h%"" end file_open (f_name: POINTER; how: INTEGER): POINTER is -- File pointer for file f_name, in mode how. -- (from FILE) external "C | %"eif_file.h%"" end file_pc (file: POINTER; c: CHARACTER) is -- Put c to end of file. -- (from FILE) external "C (FILE *, EIF_CHARACTER) | %"eif_file.h%"" end file_pd (file: POINTER; d: DOUBLE) is -- Put d to end of file. -- (from PLAIN_TEXT_FILE) external "C (FILE *, EIF_DOUBLE) | %"eif_file.h%"" end file_perm (f_name, who, what: POINTER; flag: INTEGER) is -- Change permissions for f_name to who and what. -- flag = 1 -> add permissions, -- flag = 0 -> remove permissions. -- (from FILE) external "C | %"eif_file.h%"" end file_pi (file: POINTER; n: INTEGER) is -- Put n to end of file. -- (from PLAIN_TEXT_FILE) external "C (FILE *, EIF_INTEGER) | %"eif_file.h%"" end file_pr (file: POINTER; r: REAL) is -- Put r to end of file. -- (from PLAIN_TEXT_FILE) external "C (FILE *, EIF_REAL) | %"eif_file.h%"" end file_ps (file: POINTER; a_string: POINTER; length: INTEGER) is -- Print a_string to file. -- (from FILE) external "C (FILE *, char *, EIF_INTEGER) | %"eif_file.h%"" end file_recede (file: POINTER; abs_position: INTEGER) is -- Go to absolute position, originated from end. -- (from FILE) external "C (FILE *, EIF_INTEGER) | %"eif_file.h%"" end file_rename (old_name, new_name: POINTER) is -- Change file name from old_name to new_name. -- (from FILE) external "C | %"eif_file.h%"" end file_reopen (f_name: POINTER; how: INTEGER; file: POINTER): POINTER is -- File pointer to file, reopened to have new name f_name -- in a mode specified by how. -- (from FILE) external "C (char *, EIF_INTEGER, FILE *): EIF_POINTER | %"eif_file.h%"" end file_size (file: POINTER): INTEGER is -- Size of file -- (from FILE) external "C (FILE *): EIF_INTEGER | %"eif_file.h%"" end file_tell (file: POINTER): INTEGER is -- Current cursor position in file. -- (from FILE) external "C (FILE *): EIF_INTEGER | %"eif_file.h%"" end file_tnil (file: POINTER) is -- Read upto next input line. -- (from FILE) external "C (FILE *) | %"eif_file.h%"" end file_tnwl (file: POINTER) is -- Print a new-line to file. -- (from FILE) external "C (FILE *) | %"eif_file.h%"" end file_touch (f_name: POINTER) is -- Touch file f_name. -- (from FILE) external "C | %"eif_file.h%"" end file_unlink (fname: POINTER) is -- Delete file fname. -- (from FILE) external "C | %"eif_file.h%"" end file_utime (f_name: POINTER; time, how: INTEGER) is -- Set access, modification time or both (how = 0,1,2) on -- f_name, using time as time stamp. -- (from FILE) external "C | %"eif_file.h%"" end find_referers (target: POINTER; esult: POINTER; result_size: INTEGER) is -- (from MEMORY) external "C | %"eif_traverse.h%"" end gc_monitoring (flag: BOOLEAN) is -- Set up GC monitoring according to flag -- (from MEMORY) external "C | %"eif_memory.h%"" alias "gc_mon" end mode: INTEGER -- Input-output mode -- (from FILE) Read_file: INTEGER is 1 -- (from FILE) Read_write_file: INTEGER is 4 -- (from FILE) set_buffer is -- Resynchronizes information on file -- (from FILE) require -- from FILE file_exists: exists do buffered_file_info.update (name) end set_read_mode is -- Define file mode as read. -- (from FILE) do mode := read_file end set_write_mode is -- Define file mode as write. -- (from FILE) do mode := write_file end true_string: STRING is -- Character string "true" -- (from FILE) once Result := "True" end Write_file: INTEGER is 2 -- (from FILE) feature {NONE} -- Convenience copy_to (file: like Current) is -- Copy content of current from current cursor -- position to end of file into file from -- current cursor position of file. -- (from FILE) require -- from FILE file_not_void: file /= void file_is_open_write: file.is_open_write current_is_open_read: is_open_read do read_stream (count) file.put_string (last_string) create last_string.make (256) end feature -- Input next_line is -- Move to next input line on standard input. require -- from FILE is_readable: file_readable do console_next_line (file_pointer) end read_character is -- Read a new character from standard input. -- Make result available in last_character. -- Was declared in CONSOLE as synonym of readchar. require -- from IO_MEDIUM is_readable: readable require else -- from FILE is_readable: file_readable do last_character := console_readchar (file_pointer) end read_double is -- Read a new double from standard input. -- Make result available in last_double. -- Was declared in CONSOLE as synonym of readdouble. require -- from IO_MEDIUM is_readable: readable require else -- from FILE is_readable: file_readable do last_double := console_readdouble (file_pointer) end read_integer is -- Read a new integer from standard input. -- Make result available in last_integer. -- Was declared in CONSOLE as synonym of readint. require -- from IO_MEDIUM is_readable: readable require else -- from FILE is_readable: file_readable do last_integer := console_readint (file_pointer) end read_line is -- Read a string until new line or end of file. -- Make result available in last_string. -- New line will be consumed but not part of last_string. -- Was declared in CONSOLE as synonym of readline. require -- from IO_MEDIUM is_readable: readable require else -- from FILE is_readable: file_readable require else is_readable: file_readable local str_cap: INTEGER read: INTEGER str_area: ANY done: BOOLEAN do from str_area := last_string.area str_cap := last_string.capacity until done loop read := read + console_readline (file_pointer, $str_area, str_cap, read) if read > str_cap then last_string.set_count (str_cap) if str_cap < 2048 then last_string.grow (str_cap + 1024) else last_string.automatic_grow end str_area := last_string.area str_cap := last_string.capacity read := read - 1 else last_string.set_count (read) done := True end end if read < 1024 then last_string.resize (read) end end read_real is -- Read a new real from standard input. -- Make result available in last_real. -- Was declared in CONSOLE as synonym of readreal. require -- from IO_MEDIUM is_readable: readable require else -- from FILE is_readable: file_readable do last_real := console_readreal (file_pointer) end read_stream (nb_char: INTEGER) is -- Read a string of at most nb_char bound characters -- from standard input. -- Make result available in last_string. -- Was declared in CONSOLE as synonym of readstream. require -- from IO_MEDIUM is_readable: readable require else -- from FILE is_readable: file_readable local new_count: INTEGER str_area: ANY do last_string.resize (nb_char) str_area := last_string.area new_count := console_readstream (file_pointer, $str_area, nb_char) last_string.set_count (new_count) end read_word is -- Read a new word from standard input. -- Make result available in last_string. -- Was declared in CONSOLE as synonym of readword. require -- from FILE is_readable: file_readable local str_area: ANY str_cap: INTEGER done: BOOLEAN read: INTEGER do from str_area := last_string.area str_cap := last_string.capacity until done loop read := read + console_readword (file_pointer, $str_area, str_cap, read) if read > str_cap then if str_cap < 2048 then last_string.grow (str_cap + 1024) else last_string.automatic_grow end str_area := last_string.area str_cap := last_string.capacity read := read - 1 else last_string.set_count (read) done := True end end if read < 1024 then last_string.resize (read) end separator := console_separator (file_pointer) end readchar is -- Read a new character from standard input. -- Make result available in last_character. -- Was declared in CONSOLE as synonym of read_character. require -- from IO_MEDIUM is_readable: readable require else -- from FILE is_readable: file_readable do last_character := console_readchar (file_pointer) end readdouble is -- Read a new double from standard input. -- Make result available in last_double. -- Was declared in CONSOLE as synonym of read_double. require -- from IO_MEDIUM is_readable: readable require else -- from FILE is_readable: file_readable do last_double := console_readdouble (file_pointer) end readint is -- Read a new integer from standard input. -- Make result available in last_integer. -- Was declared in CONSOLE as synonym of read_integer. require -- from IO_MEDIUM is_readable: readable require else -- from FILE is_readable: file_readable do last_integer := console_readint (file_pointer) end readline is -- Read a string until new line or end of file. -- Make result available in last_string. -- New line will be consumed but not part of last_string. -- Was declared in CONSOLE as synonym of read_line. require -- from IO_MEDIUM is_readable: readable require else -- from FILE is_readable: file_readable require else is_readable: file_readable local str_cap: INTEGER read: INTEGER str_area: ANY done: BOOLEAN do from str_area := last_string.area str_cap := last_string.capacity until done loop read := read + console_readline (file_pointer, $str_area, str_cap, read) if read > str_cap then last_string.set_count (str_cap) if str_cap < 2048 then last_string.grow (str_cap + 1024) else last_string.automatic_grow end str_area := last_string.area str_cap := last_string.capacity read := read - 1 else last_string.set_count (read) done := True end end if read < 1024 then last_string.resize (read) end end readreal is -- Read a new real from standard input. -- Make result available in last_real. -- Was declared in CONSOLE as synonym of read_real. require -- from IO_MEDIUM is_readable: readable require else -- from FILE is_readable: file_readable do last_real := console_readreal (file_pointer) end readstream (nb_char: INTEGER) is -- Read a string of at most nb_char bound characters -- from standard input. -- Make result available in last_string. -- Was declared in CONSOLE as synonym of read_stream. require -- from IO_MEDIUM is_readable: readable require else -- from FILE is_readable: file_readable local new_count: INTEGER str_area: ANY do last_string.resize (nb_char) str_area := last_string.area new_count := console_readstream (file_pointer, $str_area, nb_char) last_string.set_count (new_count) end readword is -- Read a new word from standard input. -- Make result available in last_string. -- Was declared in CONSOLE as synonym of read_word. require -- from FILE is_readable: file_readable local str_area: ANY str_cap: INTEGER done: BOOLEAN read: INTEGER do from str_area := last_string.area str_cap := last_string.capacity until done loop read := read + console_readword (file_pointer, $str_area, str_cap, read) if read > str_cap then if str_cap < 2048 then last_string.grow (str_cap + 1024) else last_string.automatic_grow end str_area := last_string.area str_cap := last_string.capacity read := read - 1 else last_string.set_count (read) done := True end end if read < 1024 then last_string.resize (read) end separator := console_separator (file_pointer) end feature {NONE} -- Iteration do_all (action: PROCEDURE [ANY, TUPLE [CHARACTER]]) is -- Apply action to every item. -- Semantics not guaranteed if action changes the structure; -- in such a case, apply iterator to clone of structure instead. -- (from LINEAR) require -- from TRAVERSABLE action_exists: action /= void local t: TUPLE [CHARACTER] do create t.make from start until after loop t.put (item, 1) action.call (t) forth end end do_if (action: PROCEDURE [ANY, TUPLE [CHARACTER]]; test: FUNCTION [ANY, TUPLE [CHARACTER], BOOLEAN]) is -- Apply action to every item that satisfies test. -- Semantics not guaranteed if action or test changes the structure; -- in such a case, apply iterator to clone of structure instead. -- (from LINEAR) require -- from TRAVERSABLE action_exists: action /= void test_exits: test /= void local t: TUPLE [CHARACTER] do create t.make from start until after loop t.put (item, 1) if test.item (t) then action.call (t) end forth end end for_all (test: FUNCTION [ANY, TUPLE [CHARACTER], BOOLEAN]): BOOLEAN is -- Is test true for all items? -- (from LINEAR) require -- from TRAVERSABLE test_exits: test /= void local cs: CURSOR_STRUCTURE [CHARACTER] c: CURSOR t: TUPLE [CHARACTER] do create t.make cs ?= Current if cs /= void then c := cs.cursor end from start Result := True until after or not Result loop t.put (item, 1) Result := test.item (t) forth end if cs /= void then cs.go_to (c) end end there_exists (test: FUNCTION [ANY, TUPLE [CHARACTER], BOOLEAN]): BOOLEAN is -- Is test true for at least one item? -- (from LINEAR) require -- from TRAVERSABLE test_exits: test /= void local cs: CURSOR_STRUCTURE [CHARACTER] c: CURSOR t: TUPLE [CHARACTER] do create t.make cs ?= Current if cs /= void then c := cs.cursor end from start until after or Result loop t.put (item, 1) Result := test.item (t) forth end if cs /= void then cs.go_to (c) end end feature -- Output new_line is -- Write line feed at end of default output. -- Was declared in CONSOLE as synonym of put_new_line. require -- from IO_MEDIUM extendible: extendible do console_tnwl (file_pointer) end put_boolean (b: BOOLEAN) is -- Write b at end of default output. -- Was declared in CONSOLE as synonym of putbool. require -- from IO_MEDIUM extendible: extendible do if b then put_string ("True") else put_string ("False") end end put_character (c: CHARACTER) is -- Write c at end of default output. -- Was declared in CONSOLE as synonym of putchar. require -- from IO_MEDIUM extendible: extendible do console_pc (file_pointer, c) end put_double (d: DOUBLE) is -- Write d at end of default output. -- Was declared in CONSOLE as synonym of putdouble. require -- from IO_MEDIUM extendible: extendible do console_pd (file_pointer, d) end put_integer (i: INTEGER) is -- Write i at end of default output. -- Was declared in CONSOLE as synonym of putint. require -- from IO_MEDIUM extendible: extendible do console_pi (file_pointer, i) end put_new_line is -- Write line feed at end of default output. -- Was declared in CONSOLE as synonym of new_line. require -- from IO_MEDIUM extendible: extendible do console_tnwl (file_pointer) end put_real (r: REAL) is -- Write r at end of default output. -- Was declared in CONSOLE as synonym of putreal. require -- from IO_MEDIUM extendible: extendible do console_pr (file_pointer, r) end put_string (s: STRING) is -- Write s at end of default output. -- Was declared in CONSOLE as synonym of putstring. require -- from IO_MEDIUM extendible: extendible non_void: s /= void local external_s: ANY do if s.count /= 0 then external_s := s.area console_ps (file_pointer, $external_s, s.count) end end putbool (b: BOOLEAN) is -- Write b at end of default output. -- Was declared in CONSOLE as synonym of put_boolean. require -- from IO_MEDIUM extendible: extendible do if b then put_string ("True") else put_string ("False") end end putchar (c: CHARACTER) is -- Write c at end of default output. -- Was declared in CONSOLE as synonym of put_character. require -- from IO_MEDIUM extendible: extendible do console_pc (file_pointer, c) end putdouble (d: DOUBLE) is -- Write d at end of default output. -- Was declared in CONSOLE as synonym of put_double. require -- from IO_MEDIUM extendible: extendible do console_pd (file_pointer, d) end putint (i: INTEGER) is -- Write i at end of default output. -- Was declared in CONSOLE as synonym of put_integer. require -- from IO_MEDIUM extendible: extendible do console_pi (file_pointer, i) end putreal (r: REAL) is -- Write r at end of default output. -- Was declared in CONSOLE as synonym of put_real. require -- from IO_MEDIUM extendible: extendible do console_pr (file_pointer, r) end putstring (s: STRING) is -- Write s at end of default output. -- Was declared in CONSOLE as synonym of put_string. require -- from IO_MEDIUM extendible: extendible non_void: s /= void local external_s: ANY do if s.count /= 0 then external_s := s.area console_ps (file_pointer, $external_s, s.count) end end invariant -- from ANY reflexive_equality: standard_is_equal (Current) reflexive_conformance: conforms_to (Current) -- from PLAIN_TEXT_FILE plain_text: is_plain_text -- from FILE valid_mode: closed_file <= mode and mode <= append_read_file name_exists: name /= void name_not_empty: not name.is_empty -- from FINITE empty_definition: is_empty = (count = 0) non_negative_count: count >= 0 -- from ACTIVE writable_constraint: writable implies readable empty_constraint: is_empty implies (not readable) and (not writable) -- from BILINEAR not_both: not (after and before) before_constraint: before implies off -- from LINEAR after_constraint: after implies off -- from TRAVERSABLE empty_constraint: is_empty implies off indexing library: "[ EiffelBase: Library of reusable components for Eiffel. ]" status: "[ Copyright 1986-2001 Interactive Software Engineering (ISE). For ISE customers the original versions are an ISE product covered by the ISE Eiffel license and support agreements. ]" license: "[ EiffelBase may now be used by anyone as FREE SOFTWARE to develop any product, public-domain or commercial, without payment to ISE, under the terms of the ISE Free Eiffel Library License (IFELL) at http://eiffel.com/products/base/license.html. ]" source: "[ Interactive Software Engineering Inc. ISE Building 360 Storke Road, Goleta, CA 93117 USA Telephone 805-685-1006, Fax 805-685-6869 Electronic mail <info@eiffel.com> Customer support http://support.eiffel.com ]" info: "[ For latest info see award-winning pages: http://eiffel.com ]" end -- class CONSOLE
Classes Clusters Cluster hierarchy Chart Relations Text Flat Contracts Flat contracts Go to:

-- Generated by ISE Eiffel --
For more details: www.eiffel.com