note description: "Directories, in the Unix sense, with creation and exploration features" library: "Free implementation of ELKS library" status: "See notice at end of class." legal: "See notice at end of class." date: "$Date: 2017-03-23 19:18:26 +0000 (Thu, 23 Mar 2017) $" revision: "$Revision: 100033 $" class DIRECTORY create make, make_with_path, make_with_name, make_open_read feature -- Initialization make (dn: READABLE_STRING_GENERAL) -- Create directory object for directory -- of name dn. require string_exists: dn /= Void do make_with_name (dn) ensure name_set: internal_name = dn end make_open_read (dn: READABLE_STRING_GENERAL) -- Create directory object for directory -- of name dn and open it for reading. require string_exists: dn /= Void do make (dn) open_read ensure name_set: internal_name = dn end make_with_name (dn: READABLE_STRING_GENERAL) -- Create directory object for directory -- of name dn. require string_exists: dn /= Void do set_name (dn) mode := Close_directory ensure name_set: internal_name = dn end make_with_path (a_path: PATH) -- Create file object with a_path as path. require a_path_attached: a_path /= Void do make (a_path.name) end feature {NONE} -- Initialization default_create -- Process instances of classes with no creation clause. -- (Default: do nothing.) -- (from ANY) do end feature -- Access change_name (new_name: READABLE_STRING_GENERAL) -- Change directory name to new_name. require new_name_not_void: new_name /= Void directory_exists: exists local l_ptr: MANAGED_POINTER do l_ptr := File_info.file_name_to_pointer (new_name, Void) eif_dir_rename (internal_name_pointer.item, l_ptr.item) set_name (new_name) ensure name_changed: internal_name = new_name end close -- Close directory. require is_open: not is_closed do dir_close (directory_pointer) directory_pointer := default_pointer mode := Close_directory end generating_type: TYPE [detachable DIRECTORY] -- Type of current object -- (type of which it is a direct instance) -- (from ANY) external "built_in" ensure -- from ANY generating_type_not_void: Result /= Void end generator: STRING_8 -- Name of current object's generating class -- (base class of the type of which it is a direct instance) -- (from ANY) external "built_in" ensure -- from ANY generator_not_void: Result /= Void generator_not_empty: not Result.is_empty end has_entry (entry_name: READABLE_STRING_GENERAL): BOOLEAN -- Has directory the entry entry_name? require string_exists: entry_name /= Void local dir_temp: DIRECTORY e: like last_entry_pointer do create dir_temp.make_open_read (internal_name) from dir_temp.start; dir_temp.readentry e := dir_temp.last_entry_pointer until Result or e = default_pointer loop if attached {READABLE_STRING_8} entry_name then Result := entry_name.same_string (File_info.pointer_to_file_name_8 (e)) elseif attached File_info.pointer_to_file_name_32 (e) as l_str then Result := entry_name.same_string (l_str) end; dir_temp.readentry e := dir_temp.last_entry_pointer end; dir_temp.close end name: STRING_8 obsolete "Use `path' to ensure you can retrieve all kind of names. [2017-05-31]" -- File name as a STRING_8 instance. The value might be truncated -- from the original name used to create the current FILE instance. do Result := internal_name.as_string_8 ensure then name_not_empty: not Result.is_empty end open_read -- Open directory for reading. do directory_pointer := dir_open (internal_name_pointer.item) mode := Read_directory end path: PATH -- Associated path of Current. do create Result.make_from_pointer (internal_name_pointer.item) ensure entry_not_empty: not Result.is_empty end readentry -- Read next directory entry -- make result available in lastentry. -- Make result Void if all entries have been read. require is_opened: not is_closed do last_entry_pointer := eif_dir_next (directory_pointer) if last_entry_pointer = default_pointer then lastentry := Void else lastentry := File_info.pointer_to_file_name_8 (last_entry_pointer) end end rename_path (new_name: PATH) -- Change directory name to new_name. require new_name_not_void: new_name /= Void new_name_not_empty: not new_name.is_empty file_exists: exists local l_ptr: MANAGED_POINTER do l_ptr := new_name.to_pointer eif_dir_rename (internal_name_pointer.item, l_ptr.item) set_name (new_name.name) ensure name_changed: internal_name = new_name.name end start -- Go to first entry of directory. require is_opened: not is_closed do directory_pointer := dir_rewind (directory_pointer, internal_name_pointer.item) end feature {NATIVE_STRING_HANDLER} -- Access pointer_length_in_bytes (a_ptr: POINTER): INTEGER_32 -- Length in bytes of a platform specific file name pointer, not -- including the null-terminating character. If size is too large -- to fit into an {INTEGER} instance, the size is truncated to -- {INTEGER_32}.max_value. -- (from NATIVE_STRING_HANDLER) require -- from NATIVE_STRING_HANDLER a_ptr_not_null: a_ptr /= default_pointer local l_length: NATURAL_64 do l_length := c_pointer_length_in_bytes (a_ptr) if l_length <= {INTEGER_32}.max_value.to_natural_64 then Result := l_length.to_integer_32 else Result := {INTEGER_32}.max_value end end feature -- Measurement count: INTEGER_32 -- Number of entries in directory. require directory_exists: exists local dir_temp: DIRECTORY do create dir_temp.make_open_read (internal_name) from dir_temp.start; dir_temp.readentry until dir_temp.last_entry_pointer = default_pointer loop Result := Result + 1; dir_temp.readentry end; dir_temp.close end feature -- Comparison frozen deep_equal (a: detachable ANY; b: like arg #1): BOOLEAN -- Are a and b either both void -- or attached to isomorphic object structures? -- (from ANY) do if a = Void then Result := b = Void else Result := b /= Void and then a.is_deep_equal (b) end ensure -- from ANY instance_free: class shallow_implies_deep: standard_equal (a, b) implies Result both_or_none_void: (a = Void) implies (Result = (b = Void)) same_type: (Result and (a /= Void)) implies (b /= Void and then a.same_type (b)) symmetric: Result implies deep_equal (b, a) end frozen equal (a: detachable ANY; b: like arg #1): BOOLEAN -- Are a and b either both void or attached -- to objects considered equal? -- (from ANY) do if a = Void then Result := b = Void else Result := b /= Void and then a.is_equal (b) end ensure -- from ANY instance_free: class definition: Result = (a = Void and b = Void) or else ((a /= Void and b /= Void) and then a.is_equal (b)) end frozen is_deep_equal alias "≡≡≡" (other: DIRECTORY): BOOLEAN -- Are Current and other attached to isomorphic object structures? -- (from ANY) require -- from ANY other_not_void: other /= Void external "built_in" ensure -- from ANY shallow_implies_deep: standard_is_equal (other) implies Result same_type: Result implies same_type (other) symmetric: Result implies other.is_deep_equal (Current) end is_equal (other: DIRECTORY): BOOLEAN -- Is other attached to an object considered -- equal to current object? -- (from ANY) require -- from ANY other_not_void: other /= Void external "built_in" ensure -- from ANY symmetric: Result implies other ~ Current consistent: standard_is_equal (other) implies Result end frozen standard_equal (a: detachable ANY; b: like arg #1): BOOLEAN -- Are a and b either both void or attached to -- field-by-field identical objects of the same type? -- Always uses default object comparison criterion. -- (from ANY) do if a = Void then Result := b = Void else Result := b /= Void and then a.standard_is_equal (b) end ensure -- from ANY instance_free: class definition: Result = (a = Void and b = Void) or else ((a /= Void and b /= Void) and then a.standard_is_equal (b)) end frozen standard_is_equal alias "≜" (other: DIRECTORY): BOOLEAN -- Is other attached to an object of the same type -- as current object, and field-by-field identical to it? -- (from ANY) require -- from ANY other_not_void: other /= Void external "built_in" ensure -- from ANY same_type: Result implies same_type (other) symmetric: Result implies other.standard_is_equal (Current) end feature -- Status report conforms_to (other: ANY): BOOLEAN -- Does type of current object conform to type -- of other (as per Eiffel: The Language, chapter 13)? -- (from ANY) require -- from ANY other_not_void: other /= Void external "built_in" end exists: BOOLEAN -- Does the directory exist? do Result := eif_dir_exists (internal_name_pointer.item) end is_closed: BOOLEAN -- Is current directory closed? do Result := mode = Close_directory end is_empty: BOOLEAN -- Is directory empty? require directory_exists: exists do Result := count = 2 end is_executable: BOOLEAN -- Is the directory executable? require directory_exists: exists do Result := eif_dir_is_executable (internal_name_pointer.item) end is_readable: BOOLEAN -- Is the directory readable? require directory_exists: exists do Result := eif_dir_is_readable (internal_name_pointer.item) end is_writable: BOOLEAN -- Is the directory writable? require directory_exists: exists do Result := eif_dir_is_writable (internal_name_pointer.item) end last_entry_32: detachable STRING_32 -- Last Unicode entry read by readentry if any. do if last_entry_pointer /= default_pointer then Result := File_info.pointer_to_file_name_32 (last_entry_pointer) end end last_entry_8: detachable STRING_8 -- Raw byte sequence of the last found entry if this entry cannot be -- expressed with Unicode characters. This is useful -- when handling a file that is not a valid UTF-8 sequence on Unix. do if last_entry_pointer /= default_pointer then Result := File_info.pointer_to_file_name_8 (last_entry_pointer) end end lastentry: detachable STRING_8 obsolete "Use `last_entry_32' for Unicode file names, or `last_entry_8' otherwise. [2017-05-31]" -- Last entry read by readentry. attribute end same_type (other: ANY): BOOLEAN -- Is type of current object identical to type of other? -- (from ANY) require -- from ANY other_not_void: other /= Void external "built_in" ensure -- from ANY definition: Result = (conforms_to (other) and other.conforms_to (Current)) end feature {NONE} -- Status report is_in_final_collect: BOOLEAN -- Is GC currently performing final collection -- after execution of current program? -- Safe to use in dispose. -- (from DISPOSABLE) external "C inline use %"eif_memory.h%"" alias "return eif_is_in_final_collect;" end feature -- Removal delete -- Delete directory if empty. require directory_exists: exists empty_directory: is_empty do eif_dir_delete (internal_name_pointer.item) end delete_content -- Delete all files located in current directory and its -- subdirectories. require directory_exists: exists do delete_content_with_action (Void, Void, 0) end delete_content_with_action (action: detachable PROCEDURE [LIST [READABLE_STRING_GENERAL]]; is_cancel_requested: detachable FUNCTION [BOOLEAN]; file_number: INTEGER_32) -- Delete all files located in current directory and its -- subdirectories. -- -- action is called each time at most file_number files has -- been deleted and before the function exits. If a_file_number -- is non-positive, action is not called. -- action may be set to Void if you don't need it. -- -- Same for is_cancel_requested. -- Make it return True to cancel the operation. -- is_cancel_requested may be set to Void if you don't need it. require directory_exists: exists valid_file_number: file_number >= 0 local l_file_name: PATH file: RAW_FILE l_info: like File_info dir: DIRECTORY dir_temp: DIRECTORY l_last_entry_pointer: like last_entry_pointer l_name: READABLE_STRING_32 file_count: INTEGER_32 deleted_files: ARRAYED_LIST [READABLE_STRING_32] requested_cancel: BOOLEAN do create deleted_files.make (file_number.min (1024)) from l_info := File_info; l_info.set_is_following_symlinks (False) create dir_temp.make_open_read (internal_name); dir_temp.start; dir_temp.readentry l_last_entry_pointer := dir_temp.last_entry_pointer until l_last_entry_pointer = default_pointer or requested_cancel loop l_name := l_info.pointer_to_file_name_32 (l_last_entry_pointer) if not l_name.same_string_general (Current_directory_string) and not l_name.same_string_general (Parent_directory_string) then l_file_name := path.extended (l_name); l_info.update (l_file_name.name) if l_info.exists then if not l_info.is_symlink and then l_info.is_directory then if dir /= Void then dir.make_with_path (l_file_name) else create dir.make_with_path (l_file_name) end; dir.recursive_delete_with_action (action, is_cancel_requested, file_number) elseif l_info.is_writable then if file /= Void then file.reset_path (l_file_name) else create file.make_with_path (l_file_name) end; file.delete; deleted_files.extend (l_file_name.name) file_count := file_count + 1 end if file_number > 0 and file_count >= file_number then if action /= Void then action (deleted_files) end if is_cancel_requested /= Void then requested_cancel := is_cancel_requested (Void) end; deleted_files.wipe_out file_count := 0 end end end; dir_temp.readentry l_last_entry_pointer := dir_temp.last_entry_pointer end; dir_temp.close if file_number > 0 and file_count > 0 and action /= Void then action (deleted_files) end rescue if dir_temp /= Void and then not dir_temp.is_closed then dir_temp.close end end dispose -- Ensure this medium is closed when garbage collected. do if not is_closed then close end end recursive_delete -- Delete directory, its files and its subdirectories. require directory_exists: exists do delete_content if is_empty then delete end end recursive_delete_with_action (action: detachable PROCEDURE [LIST [READABLE_STRING_GENERAL]]; is_cancel_requested: detachable FUNCTION [BOOLEAN]; file_number: INTEGER_32) -- Delete directory, its files and its subdirectories. -- -- action is called each time at most file_number files has -- been deleted and before the function exits. If a_file_number -- is non-positive, action is not called. require directory_exists: exists local deleted_files: ARRAYED_LIST [READABLE_STRING_GENERAL] do delete_content_with_action (action, is_cancel_requested, file_number) if attached is_cancel_requested implies not is_cancel_requested (Void) then delete if file_number > 0 and action /= Void then create deleted_files.make (1); deleted_files.extend (internal_name) action (deleted_files) end end end feature -- Conversion entries: ARRAYED_LIST [PATH] -- Entries (i.e. just the file or directory name) of current directory, -- in sequential format, in a platform specific order. local dir_temp: DIRECTORY e: like last_entry_pointer do create dir_temp.make_open_read (internal_name) create Result.make (16) from dir_temp.start; dir_temp.readentry e := dir_temp.last_entry_pointer until e = default_pointer loop Result.extend (create {PATH}.make_from_pointer (e)); dir_temp.readentry e := dir_temp.last_entry_pointer end; dir_temp.close end linear_representation: ARRAYED_LIST [STRING_8] obsolete "Use `entries' instead if your application is using Unicode file names. [2017-05-31]" -- The entries, in sequential format. -- Use entries or linear_representation_32 to get a readable version -- of the Unicode entries. local dir_temp: DIRECTORY e: like last_entry_pointer do create dir_temp.make_open_read (internal_name) create Result.make (16) from dir_temp.start; dir_temp.readentry e := dir_temp.last_entry_pointer until e = default_pointer loop Result.extend (File_info.pointer_to_file_name_8 (e)); dir_temp.readentry e := dir_temp.last_entry_pointer end; dir_temp.close end linear_representation_32: ARRAYED_LIST [STRING_32] -- The entries, in sequential format. local dir_temp: DIRECTORY e: like last_entry_pointer l_path: PATH do create dir_temp.make_open_read (internal_name) create Result.make (16) from dir_temp.start; dir_temp.readentry e := dir_temp.last_entry_pointer until e = default_pointer loop create l_path.make_from_pointer (e); Result.extend (create {STRING_32}.make_from_string (l_path.name)); dir_temp.readentry e := dir_temp.last_entry_pointer end; dir_temp.close end resolved_entries: ARRAYED_LIST [PATH] -- Entries of current directory resolved in the context of current directory (i.e. the path -- of the current directory appended with the entry) in sequential format, in a platform specific -- order. -- Compared to entries, it removes the need for callers to build the full path of the entry -- using Current. local dir_temp: DIRECTORY e: like last_entry_pointer l_path: like path do create dir_temp.make_open_read (internal_name) create Result.make (16) from dir_temp.start; dir_temp.readentry e := dir_temp.last_entry_pointer l_path := path until e = default_pointer loop Result.extend (l_path.extended_path (create {PATH}.make_from_pointer (e))); dir_temp.readentry e := dir_temp.last_entry_pointer end; dir_temp.close end feature -- Duplication frozen clone (other: detachable ANY): like other obsolete "Use `twin' instead. [2017-05-31]" -- Void if other is void; otherwise new object -- equal to other -- -- For non-void other, clone calls copy; -- to change copying/cloning semantics, redefine copy. -- (from ANY) do if other /= Void then Result := other.twin end ensure -- from ANY instance_free: class equal: Result ~ other end copy (other: DIRECTORY) -- Update current object using fields of object attached -- to other, so as to yield equal objects. -- (from ANY) require -- from ANY other_not_void: other /= Void type_identity: same_type (other) external "built_in" ensure -- from ANY is_equal: Current ~ other end frozen deep_clone (other: detachable ANY): like other obsolete "Use `deep_twin' instead. [2017-05-31]" -- Void if other is void: otherwise, new object structure -- recursively duplicated from the one attached to other -- (from ANY) do if other /= Void then Result := other.deep_twin end ensure -- from ANY instance_free: class deep_equal: deep_equal (other, Result) end frozen deep_copy (other: DIRECTORY) -- Effect equivalent to that of: -- copy (other . deep_twin) -- (from ANY) require -- from ANY other_not_void: other /= Void do copy (other.deep_twin) ensure -- from ANY deep_equal: deep_equal (Current, other) end frozen deep_twin: DIRECTORY -- New object structure recursively duplicated from Current. -- (from ANY) external "built_in" ensure -- from ANY deep_twin_not_void: Result /= Void deep_equal: deep_equal (Current, Result) end frozen standard_clone (other: detachable ANY): like other obsolete "Use `standard_twin' instead. [2017-05-31]" -- Void if other is void; otherwise new object -- field-by-field identical to other. -- Always uses default copying semantics. -- (from ANY) do if other /= Void then Result := other.standard_twin end ensure -- from ANY instance_free: class equal: standard_equal (Result, other) end frozen standard_copy (other: DIRECTORY) -- Copy every field of other onto corresponding field -- of current object. -- (from ANY) require -- from ANY other_not_void: other /= Void type_identity: same_type (other) external "built_in" ensure -- from ANY is_standard_equal: standard_is_equal (other) end frozen standard_twin: DIRECTORY -- New object field-by-field identical to other. -- Always uses default copying semantics. -- (from ANY) external "built_in" ensure -- from ANY standard_twin_not_void: Result /= Void equal: standard_equal (Result, Current) end frozen twin: DIRECTORY -- New object equal to Current -- twin calls copy; to change copying/twinning semantics, redefine copy. -- (from ANY) external "built_in" ensure -- from ANY twin_not_void: Result /= Void is_equal: Result ~ Current end feature -- Basic operations frozen as_attached: attached DIRECTORY obsolete "Remove calls to this feature. [2017-05-31]" -- Attached version of Current. -- (Can be used during transitional period to convert -- non-void-safe classes to void-safe ones.) -- (from ANY) do Result := Current end frozen default: detachable DIRECTORY -- Default value of object's type -- (from ANY) do end frozen default_pointer: POINTER -- Default value of type POINTER -- (Avoid the need to write p.default for -- some p of type POINTER.) -- (from ANY) do ensure -- from ANY instance_free: class end default_rescue -- Process exception for routines with no Rescue clause. -- (Default: do nothing.) -- (from ANY) do end frozen do_nothing -- Execute a null action. -- (from ANY) do ensure -- from ANY instance_free: class end feature {DIRECTORY} -- Implementation directory_pointer: POINTER -- Directory pointer as required in C last_entry_pointer: POINTER -- Pointer to the underlying C memory representing the last directory entry. feature {NONE} -- Implementation c_pointer_length_in_bytes (a_ptr: POINTER): NATURAL_64 -- Length in bytes of a platform specific file name pointer, not -- including the null-terminating character. -- (from NATIVE_STRING_HANDLER) require -- from NATIVE_STRING_HANDLER a_ptr_not_null: a_ptr /= default_pointer external "C inline use %"eif_eiffel.h%"" alias "{ #ifdef EIF_WINDOWS return (EIF_NATURAL_64) wcslen($a_ptr) * sizeof(wchar_t); #else return (EIF_NATURAL_64) strlen($a_ptr) * sizeof(char); #endif }" end Close_directory: INTEGER_32 = 1 Current_directory_string: STRING_8 = "." dir_close (dir_ptr: POINTER) -- Close the directory dir_ptr. external "C use %"eif_dir.h%"" alias "eif_dir_close" end dir_open (dir_name: POINTER): POINTER -- Open the directory dir_name. external "C signature (EIF_FILENAME): EIF_POINTER use %"eif_dir.h%"" alias "eif_dir_open" end dir_rewind (dir_ptr: POINTER; dir_name: POINTER): POINTER -- Rewind the directory dir_ptr with name a_name and return a new directory traversal pointer. external "C signature (EIF_POINTER, EIF_FILENAME): EIF_POINTER use %"eif_dir.h%"" alias "eif_dir_rewind" end Directory_separator_string: STRING_8 -- Constant representing the directory separator once create Result.make (1); Result.append_character (Operating_environment.Directory_separator) end eif_dir_delete (dir_name: POINTER) -- Delete the directory dir_name. external "C signature (EIF_FILENAME) use %"eif_file.h%"" alias "eif_file_unlink" end eif_dir_exists (dir_name: POINTER): BOOLEAN -- Does the directory dir_name exist? external "C signature (EIF_FILENAME): EIF_BOOLEAN use %"eif_dir.h%"" end eif_dir_is_executable (dir_name: POINTER): BOOLEAN -- Is dir_name executable? external "C signature (EIF_FILENAME): EIF_BOOLEAN use %"eif_dir.h%"" end eif_dir_is_readable (dir_name: POINTER): BOOLEAN -- Is dir_name readable? external "C signature (EIF_FILENAME): EIF_BOOLEAN use %"eif_dir.h%"" end eif_dir_is_writable (dir_name: POINTER): BOOLEAN -- Is dir_name writable? external "C signature (EIF_FILENAME): EIF_BOOLEAN use %"eif_dir.h%"" end eif_dir_next (dir_ptr: POINTER): POINTER -- Return pointer to the next entry in the current iteration. external "C use %"eif_dir.h%"" end eif_dir_rename (old_name, new_name: POINTER) -- Change directory name from old_name to new_name. external "C signature (EIF_FILENAME, EIF_FILENAME) use %"eif_file.h%"" alias "eif_file_rename" end File_info: FILE_INFO -- To avoid creating objects when querying for files. once create Result.make end file_mkdir (dir_name: POINTER) -- Make directory dir_name. external "C signature (EIF_FILENAME) use %"eif_file.h%"" alias "eif_file_mkdir" end internal_detachable_name_pointer: detachable MANAGED_POINTER note option: stable attribute end internal_name: READABLE_STRING_GENERAL -- Store the name of the file as it was given to us by the user -- to avoid conversion on storing as it is not necessary. internal_name_pointer: MANAGED_POINTER -- File system specific encoding of internal_name. -- Typically a UTF-16 sequence on Windows, a UTF-8 sequence on Unix. do if attached internal_detachable_name_pointer as l_ptr then Result := l_ptr else check internal_name_pointer_set: False then end end end mode: INTEGER_32 -- Status mode of the directory. -- Possible values are the following: Parent_directory_string: STRING_8 = ".." -- Constants to represent current (".") and parent ("..") directory. Read_directory: INTEGER_32 = 2 set_name (a_name: READABLE_STRING_GENERAL) -- Set name with a_name. do internal_name := a_name internal_detachable_name_pointer := File_info.file_name_to_pointer (a_name, internal_detachable_name_pointer) ensure name_set: internal_name = a_name end feature -- Creation create_dir -- Create a physical directory. require physical_not_exists: not exists do file_mkdir (internal_name_pointer.item) end recursive_create_dir -- Create the directory recursively. -- -- Ex: if /temp/ exists but not /temp/test, then trying -- to create /temp/test/toto will create /temp/test -- and then /temp/test/toto. local l_directory: DIRECTORY l_directories_to_build: ARRAYED_LIST [PATH] l_path: PATH l_entry: detachable PATH l_io_exception: IO_FAILURE do l_path := path.canonical_path create l_directory.make_with_path (l_path) if not l_directory.exists then from create l_directories_to_build.make (10) l_entry := l_path.entry until l_directory.exists or l_entry = Void loop l_directories_to_build.extend (l_path) l_path := l_path.parent l_entry := l_path.entry; l_directory.make_with_path (l_path) end from l_directories_to_build.finish until l_directories_to_build.before loop l_path := l_directories_to_build.item; l_directories_to_build.back; l_directory.make_with_path (l_path); l_directory.create_dir if not l_directory.exists then create l_io_exception; l_io_exception.set_description ({STRING_32}"Cannot create: " + l_path.name); l_io_exception.raise end end end ensure physical_exists: exists end feature -- Output Io: STD_FILES -- Handle to standard file setup -- (from ANY) once create Result; Result.set_output_default ensure -- from ANY instance_free: class io_not_void: Result /= Void end out: STRING_8 -- New string containing terse printable representation -- of current object -- (from ANY) do Result := tagged_out ensure -- from ANY out_not_void: Result /= Void end print (o: detachable ANY) -- Write terse external representation of o -- on standard output. -- (from ANY) local s: READABLE_STRING_8 do if attached o then s := o.out if attached {READABLE_STRING_32} s as s32 then Io.put_string_32 (s32) elseif attached {READABLE_STRING_8} s as s8 then Io.put_string (s8) else Io.put_string_32 (s.as_string_32) end end ensure -- from ANY instance_free: class end frozen tagged_out: STRING_8 -- New string containing terse printable representation -- of current object -- (from ANY) external "built_in" ensure -- from ANY tagged_out_not_void: Result /= Void end feature -- Platform Operating_environment: OPERATING_ENVIRONMENT -- Objects available from the operating system -- (from ANY) once create Result ensure -- from ANY instance_free: class operating_environment_not_void: Result /= Void end feature {NONE} -- Retrieval frozen internal_correct_mismatch -- Called from runtime to perform a proper dynamic dispatch on correct_mismatch -- from MISMATCH_CORRECTOR. -- (from ANY) local l_msg: STRING_32 l_exc: EXCEPTIONS do if attached {MISMATCH_CORRECTOR} Current as l_corrector then l_corrector.correct_mismatch else create l_msg.make_from_string ("Mismatch: ".as_string_32) create l_exc; l_msg.append (generating_type.name_32); l_exc.raise_retrieval_exception (l_msg) end end invariant name_attached: attached internal_name -- from ANY reflexive_equality: standard_is_equal (Current) reflexive_conformance: conforms_to (Current) note copyright: "Copyright (c) 1984-2017, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software 5949 Hollister Ave., Goleta, CA 93117 USA Telephone 805-685-1006, Fax 805-685-6869 Website http://www.eiffel.com Customer support http://support.eiffel.com ]" end -- class DIRECTORY
Generated by ISE EiffelStudio