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

fileio

fuzion.sys.fileio

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
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
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
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
§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

in case an error is returned (the result of this feature is false), then the size field of
the meta_data array will contain the errno for the lstat call.
§mmap(fd i64, offset i64, size i64, res Any)
 => 
Any
:
Any 
memory map a file

res[0]: 0 on success, -1 on error

return: allocated memory (same as fuzion.sys.internal_array_init.alloc)

note: offset+size must not exceed file size.
note: returning allocated memory - instead of error code - simplifies handling in DFA.
§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
§munmap(address Any, size i64)
 => 
i32
:
Any 
close a memory mapped file

return: 0 on success, -1 on error
§open(path String, flag i8)
 => 
outcome i64
:
Any 
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
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.
§seek(fd i64, offset i64)
 => 
outcome i64
:
Any 
seek offset in the stream represented by fd
returns an outcome i64 that represents the new offset
returns an error in case of failure
§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

in case an error is returned (the result of this feature is false), then the size field of
the meta_data array will contain the errno for the stat call.
writes the content of an array of bytes to a file opened as fd

this might overwrite parts or all of an existing file.