system.file watcher - Palamecia/mint GitHub Wiki

Module system.file-watcher

Description

load system.file-watcher

This module provides the System.FileWatcher class which provides an awaitable file implementation.

Packages

Enums

System.FileWatcher.Change

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

| Constant | Value | Description ||----------|-------|-------------|

| Attributes | 0x04 | The attributes of the file has changed | | Data | 0x02 | The content of the file has changed | | Name | 0x01 | The file name has changed |

Classes

System.FileWatcher

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

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

This type is not copyable

Public members

Modifiers Member Description
enum Change This enum describes the different modifications that can be watched on a file.
const getHandle Returns the event's handle as an instance of mint::handle_t.
const getPollEvent Returns the event's poll event as an instance of mint::poll_event_t.
const new Creates a new file. The file is automatically opened. The path parameter must...
const reset Reset the internal event state
const toFile Returns a System.FileWatcher.System.File instance associated with this file w...
const wait Waits until the file is modified. If timeout is given, the wait stop after ti...

Private members

Modifiers Member Description
const clone Disable object copy.
final d_ptr Object data.
@ const g_lib Global library handle.
final path Internal file path

Descriptions

System.FileWatcher.Change.Attributes

0x04

The attributes of the file has changed

System.FileWatcher.Change.Data

0x02

The content of the file has changed

System.FileWatcher.Change.Name

0x01

The file name has changed

System.FileWatcher.clone

none

Disable object copy.

System.FileWatcher.d_ptr

null

Object data.

System.FileWatcher.g_lib

lib ('libmint-system')

Global library handle.

System.FileWatcher.getHandle

def (const self)

Returns the event's handle as an instance of mint::handle_t.

System.FileWatcher.getPollEvent

def (const self)

Returns the event's poll event as an instance of mint::poll_event_t.

System.FileWatcher.new

def (self, path, flags = System.FileWatcher.Change.Data)

Creates a new file. The file is automatically opened.

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

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

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

System.FileWatcher.path

null

Internal file path

System.FileWatcher.reset

def (self)

Reset the internal event state

System.FileWatcher.toFile

def (self)

Returns a System.File instance associated with this file watcher. The returned file is opened with the same mode as the file watcher.

System.FileWatcher.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 reset.