Eiffel Media API
Overview Cluster Class Classes Index      Previous Next      Top Features

kernel.io

Class KL_PATHNAME


Direct ancestors

KI_PATHNAME, KL_IMPORTED_ARRAY_ROUTINES

Creation

Features

Invariants

indexing

description

Pathnames

library

Gobo Eiffel Kernel Library

copyright

Copyright (c) 2001, Eric Bezault and others

license

Eiffel Forum License v2 (see forum.txt)

date

$Date: 2005/08/03 21:35:47 $

revision

$Revision: 1.9 $

class

KL_PATHNAME

inherit

KI_PATHNAME

create

make

-- Create a new empty pathname.

ensure
not_relative: not is_relative

feature -- Access

any_: KL_ANY_ROUTINES

-- Routines that ought to be in class ANY

-- (From KL_IMPORTED_ANY_ROUTINES)

ensure
any_routines_not_void: Result /= Void
string_: KL_STRING_ROUTINES

-- Routines that ought to be in class STRING

-- (From KL_IMPORTED_STRING_ROUTINES)

ensure
string_routines_not_void: Result /= Void
drive: STRING

-- Drive of pathname if present,
-- Void otherwise

-- (From KI_PATHNAME)

hostname: STRING

-- Hostname of pathname if present,
-- Void otherwise
-- (for example, with UNC we can have: \\hostname\sharename)

-- (From KI_PATHNAME)

item (i: INTEGER): STRING

-- Pathname component at i-th position

-- (From KI_PATHNAME)

require
i_large_enough: i >= 1
i_small_enough: i <= count
ensure
item_not_void: Result /= Void
sharename: STRING

-- Sharename of pathname if present,
-- Void otherwise
-- (for example, with UNC we can have: \\hostname\sharename)

-- (From KI_PATHNAME)

feature -- Measurement

count: INTEGER

-- Number of components in pathname

-- (From KI_PATHNAME)

ensure
count_positive: Result >= 0

feature -- Comparison

is_equal (other: like Current): BOOLEAN

-- Is current pathname considered equal to other?

-- (From ANY)

require
other_not_void: other /= Void
ensure
symmetric: Result implies other.is_equal (Current)
consistent: standard_is_equal (other) implies Result
same_pathname (a_pathname: KI_PATHNAME): BOOLEAN

-- Is current pathname considered equal to other?

-- (From KI_PATHNAME)

require
a_pathname_not_void: a_pathname /= Void

feature -- Status report

is_canonical: BOOLEAN

-- Is pathname canonical?
-- (A pathname is canonical if it has no parent directory
-- component except at leading positions, and no current
-- directory component except when it is the only component
-- and the pathname is relative.)

-- (From KI_PATHNAME)

is_current (i: INTEGER): BOOLEAN

-- Is component at i-th position the
-- relative current directory name?

-- (From KI_PATHNAME)

require
i_large_enough: i >= 1
i_small_enough: i <= count
is_parent (i: INTEGER): BOOLEAN

-- Is component at i-th position the
-- relative parent directory name?

-- (From KI_PATHNAME)

require
i_large_enough: i >= 1
i_small_enough: i <= count
is_relative: BOOLEAN

-- Is pathname a relative pathname?

-- (From KI_PATHNAME)

feature -- Element change

append_current

-- Append current directory to pathname.

ensure
one_more: count = old count + 1
appended: is_current (count)
append_name (a_name: STRING)

-- Append component a_name to pathname.

require
a_name_not_void: a_name /= Void
ensure
one_more: count = old count + 1
appended: item (count) = a_name
append_names (a_names: ARRAY [STRING])

-- Append components a_names to pathname.

require
a_names_not_void: a_names /= Void
ensure
count_set: count = old count + a_names.count
append_parent

-- Append parent directory to pathname.

ensure
one_more: count = old count + 1
appended: is_parent (count)
set_canonical

-- Make pathname canonical.

-- (From KI_PATHNAME)

ensure
is_canonical: is_canonical

feature -- Duplication

cloned_object: like Current

-- Clone of current object

-- (From KL_CLONABLE)

ensure
cloned_not_void: Result /= Void
same_type: ANY_.same_types (Result, Current)
is_equal: Result.is_equal (Current)
copy (other: like Current)

-- Copy other to current pathname.

-- (From ANY)

require
other_not_void: other /= Void
type_identity: same_type (other)
ensure
is_equal: is_equal (other)

feature -- Setting

set_drive (a_drive: like drive)

-- Set drive to a_drive.

ensure
drive_set: drive = a_drive
set_hostname (a_hostname: like hostname)

-- Set hostname to a_hostname.

ensure
hostname_set: hostname = a_hostname
set_relative (b: BOOLEAN)

-- Set is_relative to b.

ensure
is_relative: is_relative = b
set_sharename (a_sharename: like sharename)

-- Set sharename to a_sharename.

ensure
sharename_set: sharename = a_sharename

feature {KL_PATHNAME} -- Implementation

components: ARRAY [STRING]

-- Components in pathname

invariant

components_not_void: components /= Void
components_lower: components.lower = 1
components_count: components.count >= count

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

end