Fuzion Logo
fuzion-lang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.

fileio

🌌fuzion.std.fileio

intrinsic that takes an i64 value that represents the file descriptor and closes the stream
returns an i8 to represent the result of the operation
0 in case no errors occurred and the error number in case the operation failed in the C back-end/ -1 in the interpreter
Closes an IO source using an i64 representing the source handler (file descriptor)
returns outcome unit in case of success and an error in case of failure
intrinsic that returns TRUE in case of success or FALSE in case of failure during dir creation
creates a directory using the specified path
parent directories in the path should exist otherwise, no creation will take place and an error will be the outcome
intrinsic that deletes the file/dir represented by the path returning TRUE in case of success
and FALSE in case of failure
deletes the file/dir found in the path
returns unit as outcome in case of successful deletion and error in case of failure
if the targeted dir has content, then the return value will be error and the deletion will not take place
§  file_position(fd i64, position_results Any)
 => 
unit
:
Any 
intrinsic that fills a Fuzion object with the current file stream position
and the error number from C back-end/ -1 in the interpreter
returns the current file-pointer offset as an outcome i64,
the offset is measured from the beginning of the file indicated by the file descriptor
returns the current offset in success and error in failure
intrinsic that returns the file size in bytes or -1 in case of an error
retrieves the file size in bytes and returns an outcome of error in case of an error
§  lstats(path Any, meta_data Any)
 => 
bool
:
Any 
intrinsic that fills an array with some metadata of the file/dir provided by the path
returns TRUE in case the operation was successful and FALSE in case of failure
in case the path refers to a symbolic link it does not attempt to follow it and returns info about the link itself
§  move(old_path String, new_path String)
 => 
outcome unit
:
Any 
moves file/dir from an old path to a the new path
can rename the file/dir as well by changing the name of the old file/dir to a new name in the new_path
returns a unit type as outcome in case of success and error in case of failure
§  move(old_path Any, new_path Any, _ unit)
 => 
bool
:
Any 
intrinsic that returns TRUE in case the move was successful and FALSE in case not
Opens an IO source using a Fuzion Any as path and an i8 flag to represent the opening method (Read: 0, Write: 1, Append: 2)
returns outcome i64 representing the file descriptor in success
returns an error in failure
§  open(path Any, open_results Any, flag i8)
 => 
unit
:
Any 
intrinsic that fills a Fuzion object with the file descriptor and the error number from C back-end/ -1 in the interpreter
after opening the source represented by the path parameter
reads n bytes of a file opened as fd

in case the outcome is an array, it may be shorter than n. this means the end of file
has been reached.
§  read(fd i64, file_array Any, file_array_length i32)
 => 
i64
:
Any 
intrinsic that fills an array u8 with the file bytes that is represented by the file descriptor
returns i8 0 in case of success and the error number/ -1 for the interpreter in case of failure
seek offset in the stream represented by fd
returns an outcome i64 that represents the new offset
returns an error in case of failure
§  seek(fd i64, offset i64, seek_results Any)
 => 
unit
:
Any 
intrinsic to set the file-pointer offset at which the next read or write occurs
the offset is measured from the beginning of the file indicated by the file descriptor
and fills a Fuzion object with the new offset
and the error number from the C back-end/ -1 in the interpreter
§  stats(path Any, meta_data Any)
 => 
bool
:
Any 
intrinsic that fills an array with some metadata of the file/dir provided by the path
returns TRUE in case the operation was successful and FALSE in case of failure
in case the path refers to a symbolic link it resolves it and returns info about the actual file
creates a new file using an array of u8 as content and a string as the file path
it overwrites the file, if it exists, or creates a new one if it does not exist
if the director(y/ies) in the path d(oes/o) not exist, or an error happens during the writing operation an error will be returned
in case of success a unit type will be the outcome
§  write(fd i64, content Any, content_length i32)
 => 
i8
:
Any 
intrinsic to write bytes (internal array data) in a file using the file descriptor
returns i8 0 in case of success
and the error number/ -1 in the interpreter in case of failure