class interface BINARY_FILE_WRITE
-- This class allow to write a file on the disk as a binary file
-- (ie. file containing bytes). If you need to write text in a file,
-- then consider using TEXT_FILE_WRITE.
creation
make
-- The new created object is not connected. (See also connect_to and
-- connect_for_appending_to.)
ensure
not is_connected
connect_to (new_path: STRING)
-- Truncate file to zero length or create binary file for writing.
-- The stream is positioned at the beginning of the file.
require
not is_connected;
not new_path.is_empty
ensure
is_connected implies path.same_as(new_path)
connect_for_appending_to (new_path: STRING)
-- Truncate file to zero length or create binary file for writing.
-- The stream is positioned at the beginning of the file.
require
not is_connected;
not new_path.is_empty
feature(s) from DISPOSABLE
dispose
-- Action to be executed just before garbage collection reclaims an
-- object.
require
disconnect_file_after_use: not is_connected
feature(s) from FILE
path: STRING
-- Not Void when connected to the corresponding file on the disk.
is_connected: BOOLEAN
-- Is this file connected to some file of the operating system?
ensure
definition: Result = (path /= Void)
connect_to (new_path: STRING)
-- Truncate file to zero length or create binary file for writing.
-- The stream is positioned at the beginning of the file.
require
not is_connected;
not new_path.is_empty
ensure
is_connected implies path.same_as(new_path)
disconnect
-- Disconnect from any file.
require
is_connected
ensure
not is_connected
feature(s) from BINARY_FILE_WRITE
connect_for_appending_to (new_path: STRING)
-- Truncate file to zero length or create binary file for writing.
-- The stream is positioned at the beginning of the file.
require
not is_connected;
not new_path.is_empty
flush
-- forces a write of unwritten character (write my have been
-- delayed, flush writes buffered characters)
put_byte (byte: INTEGER)
require
is_connected
put_integer_16_native_endian (i: INTEGER_16)
-- Write in the same order as the machine running this code.
-- The result is machine dependant.
require
is_connected
put_integer_16_big_endian (i: INTEGER_16)
-- Write i in big endian mode.
-- The result is machine independant.
require
is_connected
put_integer_16_little_endian (i: INTEGER_16)
-- Write i in little endian mode.
-- The result is machine independant.
require
is_connected
feature(s) from BINARY_FILE_WRITE
buffer: NATIVE_ARRAY[CHARACTER]
buffer_position: INTEGER
capacity: INTEGER
output_stream: POINTER
make
-- The new created object is not connected. (See also connect_to and
-- connect_for_appending_to.)
ensure
not is_connected
write_buffer
put_16_ne (buf: NATIVE_ARRAY[CHARACTER]; i: INTEGER_16; ch_pos: INTEGER)
put_16_le (buf: NATIVE_ARRAY[CHARACTER]; i: INTEGER_16; ch_pos: INTEGER)
put_16_be (buf: NATIVE_ARRAY[CHARACTER]; i: INTEGER_16; ch_pos: INTEGER)
binary_file_write_open (path_pointer: POINTER): POINTER
binary_file_write_append (path_pointer: POINTER): POINTER
putc (byte: CHARACTER; stream: POINTER)
fwrite (buf: NATIVE_ARRAY[CHARACTER]; size: INTEGER; stream: POINTER)
basic_flush (stream_pointer: POINTER)
fclose (stream_pointer: POINTER)
end of BINARY_FILE_WRITE