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

fileio

🌌fuzion.std.fileio

fuzion.std.fileio -- fileio presents two simple methods:

read to retrieve data from a file

write to insert data into a file

§  create_dir(path Object, path_length i32)
 => 
bool
:
Object

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
in case of successful creation a unit type will be the outcome

§  delete(path Object, path_length i32)
 => 
bool
:
Object

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

§  exists(path Object, path_length i32)
 => 
i8
:
Object

intrinsic that checks the existence of the file/directory in the path
it returns 1 in case the file/dir exists, 0 in case it does not exist and -1 in case of an error

checks if the file/directory in the path exists or not
exists is wrapped with outcome bool so it returns TRUE if the file/directory exists, FALSE if it does not and error in case of an error

§  get_file_size(path Object, path_length i32)
 => 
i64
:
Object

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

§  move(old_path string, new_path string)
 => 
outcome<unit>
:
Object

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 Object, old_path_length i32, new_path Object, new_path_length i32)
 => 
bool
:
Object

intrinsic that returns TRUE in case the move was successful and FALSE in case not

§  read(path Object, path_length i32, file_array Object, file_array_length i32)
 => 
i64
:
Object

intrinsic that fills an array u8 with the file bytes.

reads a file and returns the content as an array of u8.

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(path Object, path_length i32, content Object, content_length i32)
 => 
bool
:
Object

intrinsic to write bytes (internal array data) in a file using the file path
returns TRUE in case of success and FALSE in case of failure