TemporaryRepos

Manages a temporary folder on disk for linelist preparation artefacts. Creates, sanitises, and cleans up files within a dedicated repository directory. Automatically deletes all content on termination.

Depends on: ProjectError

Version: 1.0 (2026-02-09)

Factory helpers

create #

Build and initialise a temporary repository service

Signature:

Public Function Create(Optional ByVal baseDirectory As String) As ITemporaryRepos

Parameters:

  • baseDirectory: String. Optional custom root location.

Returns: ITemporaryRepos. Ready for use.


Lifecycle

ensure-ready #

Prepare the repository root if it has not already been created

Signature:

Public Sub EnsureReady()

reset #

Remove all temporary artefacts and mark repository as uninitialised

Signature:

Public Sub Reset()

Paths

root-path #

Fully-qualified repository root

Signature:

Public Property Get RootPath() As String

Returns: String. Absolute path ending with a path separator.


create-file-path #

Generate a safe path for a new temporary file within the repository

Signature:

Public Function CreateFilePath(ByVal fileName As String) As String

Parameters:

  • fileName: String. Requested file name (sanitised when required).

Returns: String. Absolute path ready for file creation.


File operations

delete-file #

Delete a single file; silently ignore missing paths

Signature:

Public Sub DeleteFile(ByVal path As String)

Parameters:

  • path: String. Absolute file path.

delete-all #

Remove every file within the repository, then recreate the root folder

Signature:

Public Sub DeleteAll()

Internal members (not exported)

Factory helpers

initialise #

Set the root path and mark the repository as not ready

Signature:

Friend Sub Initialise(Optional ByVal baseDirectory As String)

Parameters:


Internal helpers

resolve-root-path #

Determine the root directory used for temporary storage

Signature:

Private Function ResolveRootPath(ByVal baseDirectory As String) As String

Parameters:

Returns: String. Fully-qualified path ending with the repository folder.


ensure-directory-exists #

Create the supplied folder when missing and validate existing paths

Signature:

Private Sub EnsureDirectoryExists(ByVal folderPath As String)

Parameters:


create-directory-tree #

Create a directory and all missing parents

Signature:

Private Sub CreateDirectoryTree(ByVal folderPath As String)

Parameters:


is-directory #

Determine whether the supplied path points to a folder

Signature:

Private Function IsDirectory(ByVal path As String) As Boolean

Parameters:

Returns: Boolean. True when the path is an existing directory.


normalize-path #

Remove trailing separators and normalise the supplied path string

Signature:

Private Function NormalizePath(ByVal path As String, ByVal sep As String) As String

Parameters:

Returns: String. Cleaned path.


sanitize-file-name #

Replace characters that are invalid on common file systems

Signature:

Private Function SanitizeFileName(ByVal fileName As String) As String

Parameters:

Returns: String. Safe to append to the repository root.


delete-all-internal #

Wipe every file inside the repository without recreating the folder

Signature:

Private Sub DeleteAllInternal()

class-terminate #

Clean up temporary files when the instance is destroyed

Signature:

Private Sub Class_Terminate()

throw-error #

Raise a typed project error

Signature:

Private Sub ThrowError(ByVal errNumber As ProjectError, ByVal message As String)

Parameters:


Used in (11 file(s))