event.file - Palamecia/mint GitHub Wiki

Module

load event.file

This module provides the Event.File class which provides a waitable file implementation.

Packages

Enums

Event.File.Change

This enum describes the differents modifications that can be watched on a file.

Constant Value Description
Attributes 2 The attributes of the file has changed
Data 1 The content of the file has changed
Name 0 The file name has changed

Classes

Event.File

This class provides a waitable file implementation that trigger an event when the file is modified.

This class only provides basic file mecanisme as write and read raw data. To perform extanded operations on files, use System.File.

This type is not copyable

Members

Modifiers Member Description
+ enum Change This enum describes the differents modifications that can be watched on a file.
- const clone Disable object copy.
+ const delete Cleans up the file instance.
- final eventHandle Internal handle.
- final fileHandle Internal file access handle.
- @ g_lib Global library handle.
+ const getHandle Returns the handle used by Event.Watcher.
+ const new Creates a new file. The file is automaticaly opened. The path parameter mus...
+ const read Returns the data contained in the file from the current position to the end o...
+ const reset Reset the internal event state
+ const wait Waits until the file is modified. If timeout is given, the wait stop after ...
+ const write Writes the data in the file at the current position. This method moves the ...

Descriptions

Event.File.Change.Attributes

2

The attributes of the file has changed

Event.File.Change.Data

1

The content of the file has changed

Event.File.Change.Name

0

The file name has changed

Event.File.clone

none

Disable object copy.

Event.File.delete

def (self)

Cleans up the file instance.

Event.File.eventHandle

none

Internal handle.

Event.File.fileHandle

none

Internal file access handle.

Event.File.g_lib

lib ('libmint-event')

Global library handle.

Event.File.getHandle

def (const self)

Returns the handle used by Event.Watcher.

Event.File.new

def (self, path, mode, flags = Event.File.Change.Data)

Creates a new file. The file is automaticaly opened.

The path parameter must be a string containing the path to the file to open.

The mode parameter must be a string containing one or more flag character describing how to open the file. The following flag characters are supported:

Flag Description
r The openned file is readable.
w The openned file is writeable. If the file exists, it will be truncated.
a The openned file is writeable. If the file exists, data will be appended at the end of the file.
+ If the file is readable, write operations are also available. If the file is writable, read operations are also available.

The flags parameter must be a combination of values from the Event.File.Change enum and describes the watched events types.

If no file can be openned at the given path with the given mode, none is returned.

Event.File.read

def (self)

Returns the data contained in the file from the current position to the end of the file. This method moves the current position to the end of the file.

The file's data is contained in an instance of Serializer.DataStream.

Event.File.reset

def (self)

Reset the internal event state

Event.File.wait

def (self, timeout = none)

Waits until the file is modified. If timeout is given, the wait stop after timeout milliseconds if the file is still not modified.

Returns true if the file is modified; otherwise returns false if the wait timed out.

After a call to this method, the event is reseted.

Event.File.write

def (self, data)

Writes the data in the file at the current position. This method moves the current position to the end of the data.