GNU
|
Liberty Eiffel
|
Automated Tests
|
Wiki
|
Savannah project
|
Debian packages
|
Documentation
>
libraries
>
DIRECTORY
+
Point of view
ANY
ANY
INTERNALS_HANDLER
TYPED_INTERNALS
DIRECTORY
RECYCLING_POOL
STRING_HANDLER
ABSTRACT_STRING
STRING_RECYCLING_POOL
FILE
All features
class DIRECTORY
Summary
top
Tools for file-system directory handling. High-level facade for class
BASIC_DIRECTORY
.
Direct parents
Inherit list:
FILE
,
TRAVERSABLE
Insert list:
DIRECTORY_NOTATION_HANDLER
Class invariant
top
path
/= Void
not
exists
implies
is_empty
name /= Void
path /= Void
Overview
top
Creation features
scan
(directory_path:
ABSTRACT_STRING
)
Scans some existing
directory_path
which is supposed to be a correctly spelled directory path.
scan_current_working_directory
Scans the current working directory.
Exported features
name
:
FIXED_STRING
The directory short name.
path
:
FIXED_STRING
The directory path in use (see
scan
).
is_directory
:
BOOLEAN
is_regular
:
BOOLEAN
as_directory
: DIRECTORY
as_regular
:
REGULAR_FILE
exists
:
BOOLEAN
has_file
(a_file_name:
ABSTRACT_STRING
):
BOOLEAN
file
(a_file_name:
ABSTRACT_STRING
):
FILE
file_at
(index:
INTEGER_32
):
FILE
Access:
lower
:
INTEGER_32
Index of the first item.
upper
:
INTEGER_32
Index of the last item.
count
:
INTEGER_32
Number of items (files or directories) in Current.
is_empty
:
BOOLEAN
Is the hoard empty ?
See also
count
.
first
:
FIXED_STRING
The very
first
item.
last
:
FIXED_STRING
The
last
item.
item
(index:
INTEGER_32
):
FIXED_STRING
Return the name of entry (file or subdirectory) at
index
.
has
(entry_name:
ABSTRACT_STRING
):
BOOLEAN
Does Current contain the
entry_name
(file or subdirectory) ?
new_iterator
:
ITERATOR
[
FIXED_STRING
]
File access:
connect_to_file_stream
(file_stream:
FILE_STREAM
, filename:
STRING
)
Connect the
file
to the operating system file given by its
filename
.
parent
: DIRECTORY
enumerate
: ENUMERATE[E_]
Other features:
get_new_iterator
: ITERATOR[E_]
Agent-based features:
for_each
(action:
PROCEDURE
[
TUPLE
[TUPLE 1[E_]]])
Apply
action
to every item of
Current
.
for_all
(test:
FUNCTION
[
TUPLE
[TUPLE 1[E_]]]):
BOOLEAN
Do all items satisfy
test
?
aggregate
(action:
FUNCTION
[
TUPLE
[TUPLE 2[E_, E_], E_]], initial: E_): E_
Aggregate all the elements starting from the initial value.
Printing:
out_in_tagged_out_memory
Append terse printable representation of current object in
tagged_out_memory
.
generation
:
INTEGER_32
Agent-based features:
do_all
(action:
ROUTINE
[
TUPLE
[TUPLE 1[E_]]])
Apply
action
to every item of
Current
.
Indexing:
valid_index
(i:
INTEGER_32
):
BOOLEAN
True when
i
is valid (i.e., inside actual bounds).
name
:
FIXED_STRING
writable attribute
top
The directory short name.
path
:
FIXED_STRING
writable attribute
top
The directory path in use (see
scan
).
is_directory
:
BOOLEAN
is True
constant attribute
top
is_regular
:
BOOLEAN
is False
constant attribute
top
as_directory
: DIRECTORY
effective function
top
require
is_directory
ensure
Result = Current
as_regular
:
REGULAR_FILE
effective function
top
require
is_regular
ensure
Result = Current
exists
:
BOOLEAN
writable attribute
top
has_file
(a_file_name:
ABSTRACT_STRING
):
BOOLEAN
effective function
top
file
(a_file_name:
ABSTRACT_STRING
):
FILE
effective function
top
require
has_file
(a_file_name)
file_at
(index:
INTEGER_32
):
FILE
effective function
top
require
valid_index
(index)
lower
:
INTEGER_32
is 1
constant attribute
top
Index of the first item.
upper
:
INTEGER_32
effective function
top
Index of the last item.
count
:
INTEGER_32
effective function
top
Number of items (files or directories) in Current.
ensure
Result >= 0
is_empty
:
BOOLEAN
effective function
top
Is the hoard empty ?
See also
count
.
ensure
definition:
Result = count = 0
first
:
FIXED_STRING
effective function
top
The very
first
item.
See also
last
,
item
.
require
not is_empty
ensure
definition:
Result = item(lower)
last
:
FIXED_STRING
effective function
top
The
last
item.
See also
first
,
item
.
require
not is_empty
ensure
definition:
Result = item(upper)
item
(index:
INTEGER_32
):
FIXED_STRING
effective function
top
Return the name of entry (file or subdirectory) at
index
.
require
valid_index(index)
ensure
has
(Result)
has
(entry_name:
ABSTRACT_STRING
):
BOOLEAN
effective function
top
Does Current contain the
entry_name
(file or subdirectory) ?
require
not entry_name.is_empty
new_iterator
:
ITERATOR
[
FIXED_STRING
]
effective function
top
ensure
Result /= Void
Result.generation = generation
connect_to_file_stream
(file_stream:
FILE_STREAM
, filename:
STRING
)
effective procedure
top
Connect the
file
to the operating system file given by its
filename
.
require
not file_stream.is_connected
parent
: DIRECTORY
frozen
effective function
top
enumerate
: ENUMERATE[E_]
effective function
top
get_new_iterator
: ITERATOR[E_]
frozen
effective function
top
This feature is obsolete:
Please use new_iterator instead. This SmartEiffel historic feature is badly named.
for_each
(action:
PROCEDURE
[
TUPLE
[TUPLE 1[E_]]])
effective procedure
top
Apply
action
to every item of
Current
.
See also
for_all
,
exists_that
,
aggregate
.
require
action /= Void
for_all
(test:
FUNCTION
[
TUPLE
[TUPLE 1[E_]]]):
BOOLEAN
effective function
top
Do all items satisfy
test
?
See also
for_each
,
exists_that
,
aggregate
.
require
test /= Void
aggregate
(action:
FUNCTION
[
TUPLE
[TUPLE 2[E_, E_], E_]], initial: E_): E_
effective function
top
Aggregate all the elements starting from the initial value.
See also
for_each
,
for_all
,
exists_that
.
require
action /= Void
out_in_tagged_out_memory
effective procedure
top
Append terse printable representation of current object in
tagged_out_memory
.
generation
:
INTEGER_32
writable attribute
top
do_all
(action:
ROUTINE
[
TUPLE
[TUPLE 1[E_]]])
frozen
effective procedure
top
Apply
action
to every item of
Current
.
This feature is obsolete:
This feature is not secure because it accepts a FUNCTION, the result of which is lost. Plese use `for_each` instead.
valid_index
(i:
INTEGER_32
):
BOOLEAN
effective function
top
True when
i
is valid (i.e., inside actual bounds).
See also
lower
,
upper
,
item
.
ensure
definition:
Result =
lower
<= i and i <=
upper