indexing
	description: "Directories, in the Unix sense, with creation and exploration features"
	status: "See notice at end of class"
	date: "$Date$"
	revision: "$Revision$"

class interface
	DIRECTORY

create 

	make (dn: STRING)
			-- Create directory object for the directory
			-- of name dn.
		require
			string_exists: dn /= void

	make_open_read (dn: STRING)
			-- Create directory object for the directory
			-- of name dn and open it for reading.
		require
			string_exists: dn /= void

feature -- Initialization

	create_dir
			-- Create a physical directory.
		require
			physical_not_exists: not exists

	make (dn: STRING)
			-- Create directory object for the directory
			-- of name dn.
		require
			string_exists: dn /= void

	make_open_read (dn: STRING)
			-- Create directory object for the directory
			-- of name dn and open it for reading.
		require
			string_exists: dn /= void
	
feature -- Access

	change_name (new_name: STRING)
			-- Change file name to new_name
		require
			not_new_name_void: new_name /= void
			file_exists: exists
		ensure
			name_changed: name.is_equal (new_name)

	close
			-- Close directory.
		require
			is_open: not is_closed

	has_entry (entry_name: STRING): BOOLEAN
			-- Has directory the entry entry_name?
			-- The use of dir_temp is required not
			-- to change the position in the current
			-- directory entries list.
		require
			string_exists: entry_name /= void

	name: STRING
			-- Directory name

	open_read
			-- Open directory name for reading.

	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

	start
			-- Go to first entry of directory.
		require
			is_opened: not is_closed
	
feature -- Measurement

	count: INTEGER
			-- Number of entries in directory.
		require
			directory_exists: exists
	
feature -- Status report

	exists: BOOLEAN
			-- Does the directory exist?

	is_closed: BOOLEAN
			-- Is current directory closed?

	is_empty: BOOLEAN
			-- Is directory empty?
		require
			directory_exists: exists

	is_executable: BOOLEAN
			-- Is the directory executable?
		require
			directory_exists: exists

	is_readable: BOOLEAN
			-- Is the directory readable?
		require
			directory_exists: exists

	is_writable: BOOLEAN
			-- Is the directory writable?
		require
			directory_exists: exists

	lastentry: STRING
			-- Last entry read by readentry
	
feature -- Removal

	delete
			-- Delete directory if empty
		require
			directory_exists: exists
			empty_directory: is_empty

	delete_content
			-- Delete all files located in current directory and its
			-- subdirectories.
		require
			directory_exists: exists

	delete_content_with_action (action: PROCEDURE [ANY, TUPLE]; is_cancel_requested: FUNCTION [ANY, TUPLE, BOOLEAN]; file_number: INTEGER)
			-- Delete all files located in current directory and its
			-- subdirectories.
			--
			-- action is called each time file_number files has
			-- been deleted and before the function exits.
			-- 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

	dispose
			-- Ensure this medium is closed when garbage collected.

	recursive_delete
			-- Delete directory, its files and its subdirectories.
		require
			directory_exists: exists

	recursive_delete_with_action (action: PROCEDURE [ANY, TUPLE]; is_cancel_requested: FUNCTION [ANY, TUPLE, BOOLEAN]; file_number: INTEGER)
			-- Delete directory, its files and its subdirectories.
			--
			-- action is called each time file_number files has
			-- been deleted and before the function exits.
		require
			directory_exists: exists
	
feature -- Conversion

	linear_representation: ARRAYED_LIST [STRING]
			-- The entries, in sequential format.
	
invariant

		-- from ANY
	reflexive_equality: standard_is_equal (Current)
	reflexive_conformance: conforms_to (Current)

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 DIRECTORY