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

kernel.spec.ise

Class KL_FILE_SYSTEM


Direct ancestors

KI_FILE_SYSTEM, KL_IMPORTED_STRING_ROUTINES, KL_IMPORTED_ANY_ROUTINES, KL_SHARED_FILE_SYSTEM

Known direct descendants

KL_WINDOWS_FILE_SYSTEM, KL_UNIX_FILE_SYSTEM

Features

Invariants

indexing

description

File systems

library

Gobo Eiffel Kernel Library

copyright

Copyright (c) 2001-2004, Eric Bezault and others

license

Eiffel Forum License v2 (see forum.txt)

date

$Date: 2005/06/04 20:10:39 $

revision

$Revision: 1.24 $

deferred class

KL_FILE_SYSTEM

inherit

KI_FILE_SYSTEM

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

feature -- Status report

is_current_file_system: BOOLEAN

-- Is file system the file system of the underlying platform?

-- (From KI_FILE_SYSTEM)

feature -- File handling

concat_files (a_target_filename, a_source_filename: STRING)

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

-- (From KI_FILE_SYSTEM)

require
a_target_filename_not_void: a_target_filename /= Void
a_source_filename_not_void: a_source_filename /= Void
copy_file (old_name, new_name: STRING)

-- Copy file named old_name 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 old_name. Overwrite new_name
-- if it already existed. (old_name and new_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)

require
old_name_not_void: old_name /= Void
new_name_not_void: new_name /= Void
delete_file (a_filename: STRING)

-- Delete file named a_filename.
-- Do nothing if the file could not be
-- deleted or if it did not exist.
-- (a_dirname should follow the pathname convention
-- of the underlying platform. For pathname conversion
-- use KI_FILE_SYSTEM.pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

require
a_filename_not_void: a_filename /= Void
eol: STRING

-- Line separator in current file system

-- (From KI_FILE_SYSTEM)

ensure
eol_not_void: Result /= Void
eol_not_empty: Result.count > 0
file_count (a_filename: STRING): INTEGER

-- Number of bytes in file named a_filename;
-- Return -1 if the number of bytes was not available,
-- if the file did not exist for example.
-- (a_filename should follow the pathname convention
-- of the underlying platform. For pathname conversion
-- use KI_FILE_SYSTEM.pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

require
a_filename_not_void: a_filename /= Void
ensure
valid_values: Result = -1 or Result >= 0
file_exists (a_filename: STRING): BOOLEAN

-- Does file named a_filename physically exist on disk?
-- (Note that with SmartEiffel this routine actually returns is_readable.)
-- (a_filename should follow the pathname convention
-- of the underlying platform. For pathname conversion
-- use KI_FILE_SYSTEM.pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

require
a_filename_not_void: a_filename /= Void
file_time_stamp (a_filename: STRING): INTEGER

-- Time stamp (number of seconds since 1 January 1970
-- at 00:00:00 UTC) of last modification to file a_filename;
-- 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.)
-- (a_filename should follow the pathname convention
-- of the underlying platform. For pathname conversion
-- use KI_FILE_SYSTEM.pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

require
a_filename_not_void: a_filename /= Void
ensure
valid_values: Result = -1 or Result >= 0
is_file_readable (a_filename: STRING): BOOLEAN

-- Can file named a_filename 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.)

-- (From KI_FILE_SYSTEM)

require
a_filename_not_void: a_filename /= Void
new_input_file (a_name: STRING): KI_TEXT_INPUT_FILE

-- New input text file in current file system
-- (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)

require
a_name_not_void: a_name /= Void
ensure
input_file_not_void: Result /= Void
name_set: Result.name = a_name
is_closed: Result.is_closed
new_output_file (a_name: STRING): KI_TEXT_OUTPUT_FILE

-- New output text file in current file system
-- (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)

require
a_name_not_void: a_name /= Void
ensure
output_file_not_void: Result /= Void
name_set: Result.name = a_name
is_closed: Result.is_closed
rename_file (old_name, new_name: STRING)

-- Rename file named old_name 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. (old_name and new_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)

require
old_name_not_void: old_name /= Void
new_name_not_void: new_name /= Void
same_binary_files (a_filename1, a_filename2: STRING): BOOLEAN

-- Do files named a_filename1 and a_filename2
-- contain the same number of characters and are these
-- characters equal? Return False if one or both files
-- don't exist or cannot be open in read mode.
-- (a_filename1 and a_filename2 should follow
-- the pathname convention of the underlying
-- platform. For pathname conversion use
-- KI_FILE_SYSTEM.pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

require
a_filename1_not_void: a_filename1 /= Void
a_filename2_not_void: a_filename2 /= Void
same_physical_file (a_filename1, a_filename2: STRING): BOOLEAN

-- Are files named a_filename1 and a_filename2
-- 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.)
-- (a_filename1 and a_filename2 should follow
-- the pathname convention of the underlying
-- platform. For pathname conversion use
-- KI_FILE_SYSTEM.pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

require
a_filename1_not_void: a_filename1 /= Void
a_filename2_not_void: a_filename2 /= Void
same_text_files (a_filename1, a_filename2: STRING): BOOLEAN

-- Do files named a_filename1 and a_filename2
-- contain the same number of lines and are these
-- lines equal? Return False if one or both files
-- don't exist or cannot be open in read mode.
-- (a_filename1 and a_filename2 should follow
-- the pathname convention of the underlying
-- platform. For pathname conversion use
-- KI_FILE_SYSTEM.pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

require
a_filename1_not_void: a_filename1 /= Void
a_filename2_not_void: a_filename2 /= Void

feature -- Directory handling

create_directory (a_dirname: STRING)

-- Create a new directory named a_dirname.
-- Do nothing if the directory could not
-- be created, if it already existed or if
-- a_dirname is a nested directory name
-- and the parent directory does not exist.
-- (a_dirname should follow the pathname convention
-- of the underlying platform. For pathname conversion
-- use KI_FILE_SYSTEM.pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

require
a_dirname_not_void: a_dirname /= Void
delete_directory (a_dirname: STRING)

-- Delete directory named a_dirname.
-- Do nothing if the directory could not be deleted,
-- if it did not exist or if it is not empty.
-- (a_dirname should follow the pathname convention
-- of the underlying platform. For pathname conversion
-- use KI_FILE_SYSTEM.pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

require
a_dirname_not_void: a_dirname /= Void
directory_exists (a_dirname: STRING): BOOLEAN

-- Does directory named a_dirname physically exist on disk?
-- (Note that with SmartEiffel this routine actually returns is_readable.)
-- (a_dirname should follow the pathname convention
-- of the underlying platform. For pathname conversion
-- use KI_FILE_SYSTEM.pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

require
a_dirname_not_void: a_dirname /= Void
is_directory_readable (a_dirname: STRING): BOOLEAN

-- Can directory named a_dirname be opened in read mode?
-- (a_dirname should follow the pathname convention
-- of the underlying platform. For pathname conversion
-- use KI_FILE_SYSTEM.pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

require
a_dirname_not_void: a_dirname /= Void
recursive_copy_directory (old_name, new_name: STRING)

-- Copy recursively directory named old_name to new_name.
-- Do nothing if the directory could not be copied,
-- if it did not exist, or if new_name already existed.
-- (old_name and new_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)

require
old_name_not_void: old_name /= Void
new_name_not_void: new_name /= Void
recursive_create_directory (a_dirname: STRING)

-- Create a new directory named a_dirname on disk.
-- Create its parent directories if they do not exist yet.
-- Do nothing if the directory could not be created,
-- if it already existed or name is a nested directory
-- name and its parent directory does not exist and
-- could not be created.
-- (a_dirname should follow the pathname convention
-- of the underlying platform. For pathname conversion
-- use KI_FILE_SYSTEM.pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

require
a_dirname_not_void: a_dirname /= Void
recursive_delete_directory (a_dirname: STRING)

-- Delete directory named a_dirname, its files
-- and its subdirectories recursively. Do nothing if
-- the directory could not be deleted, if it did not exist.
-- (a_dirname should follow the pathname convention
-- of the underlying platform. For pathname conversion
-- use KI_FILE_SYSTEM.pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

require
a_dirname_not_void: a_dirname /= Void

feature -- Working directory

cd (a_dirname: STRING)

-- Set current working directory to a_dirname.
-- Do nothing if the current working directory could not
-- be changed or if directory a_dirname did not exist.
-- (a_dirname should follow the pathname convention
-- of the underlying platform. For pathname conversion
-- use KI_FILE_SYSTEM.pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

require
a_dirname_not_void: a_dirname /= Void
is_current_file_system: is_current_file_system
current_working_directory: STRING

-- Name of current working directory;
-- Return absolute pathname with the naming
-- convention of the underlying file system
-- (Return a new object at each call.)

-- (From KI_FILE_SYSTEM)

require
is_current_file_system: is_current_file_system
ensure
current_working_directory_not_void: Result /= Void
is_absolute: is_absolute_pathname (Result)
cwd: STRING

-- Name of current working directory;
-- Return absolute pathname with the naming
-- convention of the underlying file system
-- (Return a new object at each call.)

-- (From KI_FILE_SYSTEM)

require
is_current_file_system: is_current_file_system
ensure
current_working_directory_not_void: Result /= Void
is_absolute: is_absolute_pathname (Result)
set_current_working_directory (a_dirname: STRING)

-- Set current working directory to a_dirname.
-- Do nothing if the current working directory could not
-- be changed or if directory a_dirname did not exist.
-- (a_dirname should follow the pathname convention
-- of the underlying platform. For pathname conversion
-- use KI_FILE_SYSTEM.pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

require
a_dirname_not_void: a_dirname /= Void
is_current_file_system: is_current_file_system

feature -- Pathname handling

absolute_parent_directory (a_pathname: STRING): STRING

-- Absolute pathname of parent directory of a_pathname;
-- Return absolute_root_directory if a_pathname
-- is a root directory (i.e. has no parent)
-- (a_pathname should follow the pathname convention of
-- current file system: Unix convention in KL_UNIX_FILE_SYSTEM,
-- Windows convention in KL_WINDOWS_FILE_SYSTEM, etc. The
-- result also follows this pathname convention. For pathname
-- conversion use pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

require
a_pathname_not_void: a_pathname /= Void
is_current_file_system: is_current_file_system
ensure
absolute_parent_directory_not_void: Result /= Void
is_absolute: is_absolute_pathname (Result)
absolute_pathname (a_pathname: STRING): STRING

-- Absolute pathname of a_pathname
-- (a_pathname should follow the pathname convention of
-- current file system: Unix convention in KL_UNIX_FILE_SYSTEM,
-- Windows convention in KL_WINDOWS_FILE_SYSTEM, etc. The
-- result also follows this pathname convention. For pathname
-- conversion use pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

require
a_pathname_not_void: a_pathname /= Void
is_current_file_system: is_current_file_system
ensure
absolute_pathname_not_void: Result /= Void
is_absolute: is_absolute_pathname (Result)
absolute_root_directory: STRING

-- Absolute pathname of current root directory
-- (The result follows the pathname convention of current
-- file system: Unix convention in KL_UNIX_FILE_SYSTEM,
-- Windows convention in KL_WINDOWS_FILE_SYSTEM, etc. For
-- pathname conversion use pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

require
is_current_file_system: is_current_file_system
ensure
absolute_root_directory_not_void: Result /= Void
is_root: is_root_directory (Result)
is_absolute: is_absolute_pathname (Result)
basename (a_pathname: STRING): STRING

-- Pathname with any leading directory components removed
-- (a_pathname should follow the pathname convention of
-- current file system: Unix convention in KL_UNIX_FILE_SYSTEM,
-- Windows convention in KL_WINDOWS_FILE_SYSTEM, etc. The
-- result also follows this pathname convention. For pathname
-- conversion use pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

require
a_pathname_not_void: a_pathname /= Void
ensure
basename_not_void: Result /= Void
is_relative: not is_root_directory (a_pathname) implies is_relative_pathname (Result)
canonical_pathname (a_pathname: STRING): STRING

-- Canonical form of a_pathname
-- (a_pathname should follow the pathname convention of
-- current file system: Unix convention in KL_UNIX_FILE_SYSTEM,
-- Windows convention in KL_WINDOWS_FILE_SYSTEM, etc. The
-- result also follows this pathname convention. For pathname
-- conversion use pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

require
a_pathname_not_void: a_pathname /= Void
ensure
canonical_pathname_not_void: Result /= Void
dirname (a_pathname: STRING): STRING

-- Pathname containing only the leading directory components so
-- that 'pathname (dirname (a_pathname), basename (a_pathname))'
-- is equivalent to a_pathname; Return relative_current_directory
-- when there is no leading directory components in a_pathname;
-- Return a root directory when a_pathname is a root directory
-- (a_pathname should follow the pathname convention of
-- current file system: Unix convention in KL_UNIX_FILE_SYSTEM,
-- Windows convention in KL_WINDOWS_FILE_SYSTEM, etc. The
-- result also follows this pathname convention. For pathname
-- conversion use pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

require
a_pathname_not_void: a_pathname /= Void
ensure
dirname_not_void: Result /= Void
same_relative: is_relative_pathname (Result) = is_relative_pathname (a_pathname)
same_absolute: is_absolute_pathname (Result) = is_absolute_pathname (a_pathname)
exe_extension: STRING

-- Executable file extension (with the leading '.'
-- if this extension is not empty)

-- (From KI_FILE_SYSTEM)

ensure
exe_extension_not_void: Result /= Void
extension (a_filename: STRING): STRING

-- File extension of a_filename (include the leading '.')
-- (a_filename should follow the pathname convention of
-- current file system: Unix convention in KL_UNIX_FILE_SYSTEM,
-- Windows convention in KL_WINDOWS_FILE_SYSTEM, etc. For pathname
-- conversion use pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

require
a_filename_not_void: a_filename /= Void
ensure
extension_not_void: Result /= Void
has_extension (a_filename, an_extension: STRING): BOOLEAN

-- Is an_extension a file extension of a_filename?
-- (a_filename should follow the pathname convention of
-- current file system: Unix convention in KL_UNIX_FILE_SYSTEM,
-- Windows convention in KL_WINDOWS_FILE_SYSTEM, etc. For pathname
-- conversion use pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

require
a_filename_not_void: a_filename /= Void
an_extension_not_void: an_extension /= Void
is_absolute_pathname (a_pathname: STRING): BOOLEAN

-- Is a_pathname an absolute pathname?
-- (a_pathname should follow the pathname convention of
-- current file system: Unix convention in KL_UNIX_FILE_SYSTEM,
-- Windows convention in KL_WINDOWS_FILE_SYSTEM, etc. For pathname
-- conversion use pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

require
a_pathname_not_void: a_pathname /= Void
ensure
not_relative: Result implies not is_relative_pathname (a_pathname)
is_relative_pathname (a_pathname: STRING): BOOLEAN

-- Is a_pathname a relative pathname (relative
-- to the current working directory)?
-- (a_pathname should follow the pathname convention of
-- current file system: Unix convention in KL_UNIX_FILE_SYSTEM,
-- Windows convention in KL_WINDOWS_FILE_SYSTEM, etc. For pathname
-- conversion use pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

require
a_pathname_not_void: a_pathname /= Void
ensure
not_absolute: Result implies not is_absolute_pathname (a_pathname)
is_root_directory (a_dirname: STRING): BOOLEAN

-- Is a_dirname a root directory (i.e. it has no parent directory)?
-- (a_dirname should follow the pathname convention of
-- current file system: Unix convention in KL_UNIX_FILE_SYSTEM,
-- Windows convention in KL_WINDOWS_FILE_SYSTEM, etc. For pathname
-- conversion use pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

require
a_dirname_not_void: a_dirname /= Void
nested_pathname (a_dirname: STRING; a_pathnames: ARRAY [STRING]): STRING

-- Pathname made up of relative pathnames
-- a_pathnames in directory a_dirname
-- (a_dirname and a_pathnames should follow the pathname convention
-- of current file system: Unix convention in KL_UNIX_FILE_SYSTEM,
-- Windows convention in KL_WINDOWS_FILE_SYSTEM, etc. The
-- result also follows this pathname convention. For pathname
-- conversion use pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

require
a_dirname_not_void: a_dirname /= Void
a_pathnames_not_void: a_pathnames /= Void
a_pathnames_not_empty: a_pathnames.count > 0
ensure
pathname_not_void: Result /= Void
same_relative: is_relative_pathname (Result) = is_relative_pathname (a_dirname)
same_absolute: is_absolute_pathname (Result) = is_absolute_pathname (a_dirname)
pathname (a_dirname, a_pathname: STRING): STRING

-- Pathname made up of relative pathname
-- a_pathname in directory a_dirname
-- (a_dirname and a_pathname should follow the pathname convention
-- of current file system: Unix convention in KL_UNIX_FILE_SYSTEM,
-- Windows convention in KL_WINDOWS_FILE_SYSTEM, etc. The
-- result also follows this pathname convention. For pathname
-- conversion use pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

require
a_dirname_not_void: a_dirname /= Void
a_pathname_not_void: a_pathname /= Void
a_pathname_relative: is_relative_pathname (a_pathname)
ensure
pathname_not_void: Result /= Void
same_relative: is_relative_pathname (Result) = is_relative_pathname (a_dirname)
same_absolute: is_absolute_pathname (Result) = is_absolute_pathname (a_dirname)
pathname_from_file_system (a_pathname: STRING; a_file_system: KI_FILE_SYSTEM): STRING

-- Pathname using pathname convention of current file system
-- (Unix convention in KL_UNIX_FILE_SYSTEM, Windows convention
-- in KL_WINDOWS_FILE_SYSTEM, etc.) converted from a_pathname
-- which should follow the pathname convention of a_file_system

-- (From KI_FILE_SYSTEM)

require
a_pathname_not_void: a_pathname /= Void
a_file_system_not_void: a_file_system /= Void
ensure
pathname_from_not_void: Result /= Void
pathname_to_string (a_pathname: KI_PATHNAME): STRING

-- Convert pathname to string
-- (The result follows the pathname convention of current
-- file system: Unix convention in KL_UNIX_FILE_SYSTEM,
-- Windows convention in KL_WINDOWS_FILE_SYSTEM, etc. For
-- pathname conversion use pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

require
a_pathname_not_void: a_pathname /= Void
ensure
pathname_to_string_not_void: Result /= Void
relative_current_directory: STRING

-- Relative pathname of current directory
-- (The result follows the pathname convention of current
-- file system: Unix convention in KL_UNIX_FILE_SYSTEM,
-- Windows convention in KL_WINDOWS_FILE_SYSTEM, etc. For
-- pathname conversion use pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

ensure
relative_current_directory_not_void: Result /= Void
is_relative: is_relative_pathname (Result)
relative_parent_directory: STRING

-- Relative pathname of current parent directory
-- (The result follows the pathname convention of current
-- file system: Unix convention in KL_UNIX_FILE_SYSTEM,
-- Windows convention in KL_WINDOWS_FILE_SYSTEM, etc. For
-- pathname conversion use pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

ensure
relative_parent_directory_not_void: Result /= Void
is_relative: is_relative_pathname (Result)
root_directory: STRING

-- Pathname of current root directory
-- (The result follows the pathname convention of current
-- file system: Unix convention in KL_UNIX_FILE_SYSTEM,
-- Windows convention in KL_WINDOWS_FILE_SYSTEM, etc. For
-- pathname conversion use pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

ensure
root_directory_not_void: Result /= Void
is_root: is_root_directory (Result)
not_relative: not is_relative_pathname (Result)
string_to_pathname (a_pathname: STRING): KI_PATHNAME

-- Convert string to pathname
-- (a_pathname should follow the pathname convention of
-- current file system: Unix convention in KL_UNIX_FILE_SYSTEM,
-- Windows convention in KL_WINDOWS_FILE_SYSTEM, etc. For pathname
-- conversion use pathname_from_file_system.)

-- (From KI_FILE_SYSTEM)

require
a_pathname_not_void: a_pathname /= Void
ensure
string_to_pathname_not_void: Result /= Void

invariant


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

end