Table of Contents

Class NcResultFolders

Namespace
Hi.MachiningProcs
Assembly
HiNc.dll

Internal Use Only. The result folders of a project (the NC play result recording's P3): each recording section leaves one folder under the results directory (Output/results by default), named [NcName]-[timestamp], holding result.db and, when the stock could be written, finish.wct. The folders accumulate – nothing deletes a completed result but Delete(string) – and the latest is found by its creation time; the project file keeps no pointer to them. An orphan is a folder whose recording never completed – crashed or abandoned; DeleteOrphans(string, IProgress<IMessage>, string) removes them on request (the recorder's host only says they are there when a recording begins), repairs a file whose completion was refused, and leaves alone what it could not read or what a connection still holds. Nothing here deletes a completed result but Delete(string). A delete takes the files a recording writes (result.db, its side files, finish.wct) and then the folder, when nothing else is left in it: what the user put in a result folder, or the result folders a template without tokens put inside another, stays.

public static class NcResultFolders
Inheritance
NcResultFolders
Inherited Members

Methods

Delete(string)

Deletes one result folder: the files a recording writes in it (result.db, its side files, finish.wct), then the folder when nothing else is left in it. Only a folder that holds a result.db is touched: the method refuses any other folder, so a wrong path cannot take a project folder with it; and a file a connection holds in WAL mode – a recording in progress, here or in another program – is refused, on every system.

public static bool Delete(string resultDirectory)

Parameters

resultDirectory string

The result folder's path.

Returns

bool

True when the folder went too; false when it keeps entries the recording did not write.

Exceptions

ArgumentNullException

resultDirectory is null.

ArgumentException

The folder holds no result.db.

IOException

A connection holds the file (a recording in progress), or a file of the result could not be deleted (a file held open, among others).

DeleteOrphans(string, IProgress<IMessage>, string)

Deletes the orphans under resultsDirectory: the result folders whose file opened and holds a recording that was never completed (crashed or abandoned: no counts written). A file whose completion was refused – the records and the counts in, the file left in WAL mode – is repaired instead (TryFinalize(string)) and kept. Left alone and said: a file a connection holds – of this program or another; on Windows a file any program holds open refuses an exclusive open before it is looked at, and on every system a file a connection holds in WAL mode (a recording in progress) is found by SQLite's own locks before it is deleted – a file that is no result file this build reads (another kind of SQLite file, a newer schema), a file that could not be read, and a folder that cannot be deleted. The folder being recorded is left out. A deleted orphan's folder keeps what the recording did not write (Delete(string)).

public static int DeleteOrphans(string resultsDirectory, IProgress<IMessage> progress, string excludeDirectory = null)

Parameters

resultsDirectory string

The results directory; one that does not exist holds nothing.

progress IProgress<IMessage>

Where each deletion, each repair and each skip is said; null for silence.

excludeDirectory string

A folder to leave out: the one being recorded; null for none.

Returns

int

How many folders were deleted.

Exceptions

ArgumentNullException

resultsDirectory is null.

Enumerate(string, string)

Lists the result folders under resultsDirectory: its direct sub-folders that hold a result.db, the newest first (by the file's creation time; a file that did not open last, by name). Each file's metadata alone is read on a read-only connection closed again; a file a crashed amend left with a hot journal beside it is rolled back first, on a read-write connection that changes nothing else.

public static IReadOnlyList<NcResultEntry> Enumerate(string resultsDirectory, string excludeDirectory = null)

Parameters

resultsDirectory string

The results directory; one that does not exist lists nothing.

excludeDirectory string

A folder to leave out and not open: the one being recorded (its file is in use and not complete); null for none.

Returns

IReadOnlyList<NcResultEntry>

The entries, newest first.

Exceptions

ArgumentNullException

resultsDirectory is null.