RunicWatchTarget class

Namespace Runic.Application.Views in Runic.Application.Views 0.23.0

public sealed class RunicWatchTarget

A file, symbolic link, directory or Git checkout that a RunicPathWatcher observes.

Remarks

A target is compared by reference: the RunicPathChange.Targets of a change are the instances that were passed to RunicPathWatcher.Start.

Properties

Path

public string Path { get; }

Gets the path this target was created with.

Methods

Directory

public static RunicWatchTarget Directory(string path, string pattern = "*")

Watches the entries of one directory whose names match pattern: one is added, removed or renamed. Writes to an entry do not count, nor does an entry replaced by renaming another file over it; use RunicWatchTarget.Files for those. Subdirectories are not searched.

Parameters

path

The directory's path. It need not exist.

pattern

A simple pattern with * and ?, such as system-*-link, matched with the platform's file-name casing.

File

public static RunicWatchTarget File(string path)

Watches one file: it is created, deleted, replaced, renamed or written. A symbolic link at the path counts as changed when it is re-pointed, not when the file it points to changes; use RunicWatchTarget.Link to follow it.

Parameters

path

The file's path. It need not exist.

Files

public static RunicWatchTarget Files(string path, string pattern = "*")

Watches each entry of one directory whose name matches pattern as RunicWatchTarget.File watches one file: an entry is added, removed, renamed, written, or replaced, as when a program writes a temporary file and renames it over the entry to update it atomically. Subdirectories are not searched.

Parameters

path

The directory's path. It need not exist.

pattern

A simple pattern with * and ?, such as *.json, matched with the platform's file-name casing.

Remarks

An event that names a matching entry counts, as for RunicWatchTarget.File; a temporary file whose name does not match is ignored until it is renamed to one that does. Where the watcher polls, it compares each entry's size and write time, so it reads every matching entry's metadata on each poll: prefer a pattern that matches only the entries of interest.

GitHead

public static RunicWatchTarget GitHead(string repository)

Watches the commit a Git checkout's HEAD resolves to: a commit, reset, checkout or switch to another branch, including in a linked worktree, whose .git is a file.

Parameters

repository

The checkout's root, which contains .git, or a bare repository.

Remarks

The watcher reads HEAD, the loose ref and packed-refs itself and starts no git process. Packing refs, fetching and changes to other branches do not count. With the reftable ref format, any update of the reftable stack counts. Changes to the work tree and the index are not watched.

public static RunicWatchTarget Link(string path)

Watches where a symbolic link leads: the target changes when the link, or a link it leads through, is created, removed or re-pointed so that the final path differs, as when /run/current-system or a Nix profile link is replaced by a rename.

Parameters

path

The link's path. It need not exist.

Remarks

Changes inside the final file or directory are not reported; Nix store paths never change. Directories in the path that are themselves symbolic links are resolved once, when the watcher evaluates the target.

ToString

public override string ToString()

Inherits documentation from Object.ToString.