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

kernel.io

Class KI_FILE


Direct ancestors

KI_FILE_SYSTEM_ENTRY

Known direct descendants

KI_INPUT_FILE, KI_OUTPUT_FILE, KL_FILE

Features

Invariants

indexing

description

Interface for files

library

Gobo Eiffel Kernel Library

copyright

Copyright (c) 2001, Eric Bezault and others

license

Eiffel Forum License v2 (see forum.txt)

date

$Date: 2005/03/07 00:18:53 $

revision

$Revision: 1.11 $

deferred class

KI_FILE

inherit

KI_FILE_SYSTEM_ENTRY

feature -- Initialization

reset (a_name: STRING)

-- Reuse current Eiffel object memory to
-- represent a new file system entry.
-- (a_name should follow the pathname convention
-- of the underlying platform. For pathname conversion
-- use KI_FILE_SYSTEM.pathname_from_file_system.)

-- (From KI_FILE_SYSTEM_ENTRY)

require
a_name_not_void: a_name /= Void
is_closed: is_closed
ensure
name_set: name = a_name
is_closed: is_closed

feature -- Access

name: STRING

-- File system entry name

-- (From KI_FILE_SYSTEM_ENTRY)

ensure
name_not_void: Result /= Void
time_stamp: INTEGER

-- Time stamp (number of seconds since 1 January 1970
-- at 00:00:00 UTC) of last modification to current file;
-- Return -1 if the time stamp was not available, if the
-- file did not exist for example, or if the time stamp
-- didn't fit into an INTEGER. (Use DT_DATE_TIME.make_from_epoch
-- to convert this time stamp to a human readable format.)

ensure
valid_values: Result = -1 or Result >= 0

feature -- Measurement

count: INTEGER

-- Number of bytes in current file;
-- Return -1 if the number of bytes was not available,
-- if the file did not exist for example.

require
is_closed: is_closed
ensure
valid_values: Result = -1 or Result >= 0

feature -- Status report

exists: BOOLEAN

-- Does file system entry physically exist on disk?
-- (Note that with SmartEiffel this routine actually
-- returns is_readable.)

-- (From KI_FILE_SYSTEM_ENTRY)

is_closable: BOOLEAN

-- Can current file system entry be closed?

-- (From KI_FILE_SYSTEM_ENTRY)

ensure
definition: Result = is_open
is_closed: BOOLEAN

-- Is file system entry closed?

-- (From KI_FILE_SYSTEM_ENTRY)

ensure
definition: Result = not is_open
is_open: BOOLEAN

-- Has file system entry been opened?

-- (From KI_FILE_SYSTEM_ENTRY)

is_readable: BOOLEAN

-- Can file system entry be opened in read mode?

-- (From KI_FILE_SYSTEM_ENTRY)

ensure
exists: Result implies exists
same_physical_file (other_name: STRING): BOOLEAN

-- Are current file and file named other_name
-- the same physical file? Return False if one
-- or both files don't exist. (Return True if
-- it was impossible to determine whether the
-- files were physically the same files.)
-- (other_name should follow the pathname convention
-- of the underlying platform. For pathname conversion
-- use KI_FILE_SYSTEM.pathname_from_file_system.)

require
other_name_not_void: other_name /= Void
is_closed: is_closed

feature -- Basic operations

change_name (new_name: STRING)

-- Rename current file as new_name.
-- Do nothing if the file could not be renamed, if
-- it did not exist or if new_name is physically
-- the same file as current file. Overwrite new_name
-- if it already existed. If renaming was successful,
-- then name is set to new_name.
-- (new_name should follow the pathname convention
-- of the underlying platform. For pathname conversion
-- use KI_FILE_SYSTEM.pathname_from_file_system.)

require
new_name_not_void: new_name /= Void
is_closed: is_closed
close

-- Try to close file system entry. Set is_closed
-- to true if operation was successful.

-- (From KI_FILE_SYSTEM_ENTRY)

require
is_closable: is_closable
concat (a_filename: STRING)

-- Copy content of file a_filename to the end of current file.
-- Do nothing if file a_filename does not exist. Create
-- current file if it does not exist yet. If file a_filename
-- is physically the same as current file, then a copy of
-- the file is appended to itself. Do nothing if current
-- file could not be open in append mode or if file a_filename
-- could not be opened in read mode.
-- (a_filename should follow the pathname convention
-- of the underlying platform. For pathname conversion
-- use KI_FILE_SYSTEM.pathname_from_file_system.)

require
a_filename_not_void: a_filename /= Void
is_closed: is_closed
copy_file (new_name: STRING)

-- Copy current file to new_name.
-- Do nothing if the file could not be copied, if it
-- did not exist or if new_name is physically
-- the same file as current file. Overwrite new_name
-- if it already existed.
-- (new_name should follow the pathname convention
-- of the underlying platform. For pathname conversion
-- use KI_FILE_SYSTEM.pathname_from_file_system.)

require
new_name_not_void: new_name /= Void
is_closed: is_closed
delete

-- Delete current file system entry.
-- Do nothing if the entry could not be deleted
-- (for example if the entry does not exist or
-- if a directory is not empty).

-- (From KI_FILE_SYSTEM_ENTRY)

require
is_closed: is_closed
open

-- Try to open file system entry. Set is_open
-- to true if operation was successful.

-- (From KI_FILE_SYSTEM_ENTRY)

require
is_closed: is_closed

invariant


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

end