Skip to content

@fs

File System interaction module.
Module Includes: @string, @bytes

enum FSError

deen
  None,
  WriteableModeException,
  ReadableModeException,
  StdlibException,
  NullFileBuffer

enum FileMode

deen
  Read,
  ReadBinary,

  Write,
  WriteBinary,

  Append,
  AppendBinary,

  ReadWrite,
  ReadAppend

struct ModeHandler

deen
// PRIVATE STRUCTURE
// No fields

Methods:

fn specify(mode: FileMode) *char
Specifies filemode to C format

struct ModeHandler

deen
// No fields

Methods:

fn specify(err: FSError) *char
Specifies filesystem error to human readable.

struct File

deen
path: String,
mode: FileMode,
is_open: bool,
error_state: FSError,
size: usize,
ptr: *void

Methods:

fn open(filename: *char, mode: FileMode) File
Opens provided file. Opened and error status are in is_open and error_state fields.


fn close(&self) FSError
Closes file buffer and returns status.


fn opened(&self) bool
Returns if file is opened.


fn size(&self) usize
Returns opened file size.


fn get_error(&self) FSError
Returns current error state.


fn specify_error(&self) *char
Specifies current error state to human readable.


fn rewind(&self)
Rewinds file buffer if it open.


fn get_char(&self) char
Reads character from file buffer. If it's closed or EOF returns '\0'


fn read(&self) Bytes
Reads whole file to Bytes structure.


fn read_string(&self) String
Reads whole file to String structure.


fn write(&self, bytes: *Bytes) FSError
Writes bytes buffer to file and returns error state.


fn write_string(&self, value: *String) FSError
Write dynamic string buffer to file and returns error state.


fn write_str(&self, value: *char) FSError
Writes CStr value to file and returns error state.

Compiler Implementations:

  • fn drop(&self)

For more information see Structures Implementations