INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES

indexing

title: "Files viewed as streams"
project: "Eiffel Kernel Library: input and output"
revision: "$Revision: 1.1 $"
copyright: "Copyright (C) 1996-2005 Object Tools Group"
license: "http://visual-eiffel.com/license"
cluster: kernel
class FILE_STREAM
inherit

PROCESS_STREAM
export
{STORABLE, TEXTFILE}
handle
redefine
close
end

PROCESS_INPUT_STREAM
rename
is_open as is_open_read
undefine
close
end

PROCESS_OUTPUT_STREAM
rename
is_open as is_open_write
undefine
close
end
creation

make,
make_create_read_write,
make_open_append,
make_open_read,
make_open_read_write,
make_open_write,
make_temporary
feature {NONE}-- Creation

make (fn: STRING)
-- Create file object with 'fn' as file name
require
string_exists: fn /= void
string_not_empty: not fn.is_empty
ensure
file_named: name.is_equal (fn)
file_closed: is_closed

make_create_read_write (fn: STRING)
-- Create file object with 'fn' as file name
-- and open file for both reading and writing;
-- create it if it does not exist
require
string_exists: fn /= void
string_not_empty: not fn.is_empty
ensure
exists: exists
open_read: is_open_read
open_write: is_open_write

make_open_append (fn: STRING)
-- Create file object with 'fn' as file name
-- and open file in append-only mode
require
string_exists: fn /= void
string_not_empty: not fn.is_empty
ensure
exists: exists
open_append: is_open_append

make_open_read (fn: STRING)
-- Create file object with 'fn' as file name
-- and open file in read mode
require
string_exists: fn /= void
string_not_empty: not fn.is_empty
ensure
exists: exists
open_read: is_open_read

make_open_read_write (fn: STRING)
-- Create file object with 'fn' as file name
-- and open file for both reading and writing
require
string_exists: fn /= void
string_not_empty: not fn.is_empty
ensure
exists: exists
open_read: is_open_read
open_write: is_open_write

make_open_write (fn: STRING)
-- Create file object with 'fn' as file name
-- and open file for writing;
-- create it if it does not exist
require
string_exists: fn /= void
string_not_empty: not fn.is_empty
ensure
exists: exists
open_write: is_open_write

make_temporary
-- Create temporary file for reading and writing.
-- The file will be deleted on close.
ensure
exists: exists
open_read: is_open_read
open_write: is_open_write
feature -- Access

name: STRING
feature -- Status report

exists: BOOLEAN
-- Does physical file exist?

is_open_read: BOOLEAN
-- Is file open for reading?
ensure
false_if_closed: is_closed implies not Result

is_open_write: BOOLEAN
-- Is file open for writing?
ensure
false_if_closed: is_closed implies not Result

is_open_append: BOOLEAN
-- Is file open for appending?
ensure
false_if_closed: is_closed implies not Result
feature -- Status setting

open_read
-- Open file in read-only mode
require
is_closed: is_closed
ensure
exists: exists
open_read: is_open_read

open_append
-- Open file in write-at-end mode;
-- create it if it does not exist
require
is_closed: is_closed
ensure
exists: exists
open_append: is_open_append

open_read_write
-- Open file in read and write mode
require
is_closed: is_closed
ensure
exists: exists
open_read: is_open_read
open_write: is_open_write

open_write
-- Open file in write-only mode;
-- create it if it does not exist
require
is_closed: is_closed
ensure
exists: exists
open_write: is_open_write

create_read_write
-- Open file in read and write mode;
-- create it if it does not exist
require
is_closed: is_closed
ensure
exists: exists
open_read: is_open_read
open_write: is_open_write

close
-- Close file
feature -- Positioning

rewind_begin (offset: INTEGER)
-- Move file pointer to the given offset
-- from the beginning of the file
require
is_open: not is_closed
end -- class FILE_STREAM

INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES