TemporaryRepos
Owns one folder on disk that a linelist build writes its working files into. Create takes the base directory, or falls back to the default one. RootPath answers the folder, EnsureReady creates it, and CreateFilePath builds a path inside it from a file name it cleans first. DeleteFile removes one file, DeleteAll empties the folder and creates it again, Reset empties it and marks the object as needing another EnsureReady, and Remove empties it and deletes the folder itself. Terminating an instance empties the folder.
THE KEPT FILE
A build that fails saves its unfinished workbook in this folder and drops the instance right after. KeepFile marks one file name to survive that drop: Class_Terminate deletes every other file and leaves the marked ones. Reset, DeleteAll and Remove are explicit calls and wipe the folder whole, marks included, so the next run that saves its linelist starts clean.
Depends on: ProjectError
Version: 1.2 (2026-09-01)
Factory helpers
Create #
create
Build and initialise a temporary repository service
Signature:
Public Function Create(Optional ByVal baseDirectory As String) As TemporaryRepos
Parameters:
baseDirectory: String. Optional custom root location.
Returns: TemporaryRepos. Ready for use.
Lifecycle
EnsureReady #
ensure-ready
Prepare the repository root if it has not already been created
Signature:
Public Sub EnsureReady()
Reset #
reset
Remove all temporary artefacts and mark repository as uninitialised
Signature:
Public Sub Reset()
The kept marks go with the files: a reset repository starts clean.
Remove #
remove
Remove every file and the folder itself
Signature:
Public Sub Remove()
What Reset does, and then the folder goes too. A build that reached its save calls this, so the working folder is not left behind next to the linelist it wrote.
The folder is removed only when it is empty. A removal the file system refuses -- a file this class cannot see, a folder another program holds open -- is left alone: the files this class wrote are gone either way, and the next EnsureReady creates the folder again.
Paths
RootPath #
root-path
Fully-qualified repository root
Signature:
Public Property Get RootPath() As String
Returns: String. Absolute path ending with a path separator.
CreateFilePath #
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
DeleteFile #
delete-file
Delete a single file; silently ignore missing paths
Signature:
Public Sub DeleteFile(ByVal path As String)
Parameters:
path: String. Absolute file path.
DeleteAll #
delete-all
Remove every file within the repository, then recreate the root folder
Signature:
Public Sub DeleteAll()
The kept marks go with the files, the way Reset drops them.
KeepFile #
keep-file
Mark one file of the repository to survive the drop of the instance
Signature:
Public Sub KeepFile(ByVal fileName As String)
The name is cleaned the way CreateFilePath cleans it, so the mark matches the file that call wrote. Marking the same name twice is one mark. The mark holds until Reset or DeleteAll wipes the folder.
Parameters:
fileName: String. The file name inside the repository.
Internal members (not exported)
Factory helpers
Initialise #
initialise
Set the root path and mark the repository as not ready
Signature:
Friend Sub Initialise(Optional ByVal baseDirectory As String)
Parameters:
baseDirectory: String. Optional custom root location.
File operations
IsKept #
is-kept
Whether a file name carries the keep mark
Signature:
Private Function IsKept(ByVal fileName As String) As Boolean
Parameters:
fileName: String. The bare file name.
Returns: Boolean. True when KeepFile marked it.
Internal helpers
ResolveRootPath #
resolve-root-path
Determine the root directory used for temporary storage
Signature:
Private Function ResolveRootPath(ByVal baseDirectory As String) As String
Parameters:
baseDirectory: String. Optional path supplied by the caller.
Returns: String. Fully-qualified path ending with the repository folder.
EnsureDirectoryExists #
ensure-directory-exists
Create the supplied folder when missing and validate existing paths
Signature:
Private Sub EnsureDirectoryExists(ByVal folderPath As String)
Parameters:
folderPath: String. Path that should represent a directory.
CreateDirectoryTree #
create-directory-tree
Create a directory and all missing parents
Signature:
Private Sub CreateDirectoryTree(ByVal folderPath As String)
Parameters:
folderPath: String. Fully-qualified target folder.
IsDirectory #
is-directory
Determine whether the supplied path points to a folder
Signature:
Private Function IsDirectory(ByVal path As String) As Boolean
Parameters:
path: String. Path to test.
Returns: Boolean. True when the path is an existing directory.
NormalizePath #
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:
path: String. Raw path.sep: String. Platform path separator.
Returns: String. Cleaned path.
SanitizeFileName #
sanitize-file-name
Replace characters that are invalid on common file systems
Signature:
Private Function SanitizeFileName(ByVal fileName As String) As String
Parameters:
fileName: String. Candidate file name.
Returns: String. Safe to append to the repository root.
DeleteAllInternal #
delete-all-internal
Wipe every file inside the repository, keeping the folder itself
Signature:
Private Sub DeleteAllInternal(Optional ByVal skipKept As Boolean = False)
The whole listing is read before the first file is deleted. Dir$ walks one folder through state the host holds, and deleting an entry part way through that walk makes the rest of the listing unreliable, so files were left behind. The listing is small: this folder holds the working files of one generation.
A file KeepFile marked is left alone when skipKept is True, which is what the instance drop asks for. The explicit wipes pass False.
Parameters:
skipKept: Optional Boolean. True leaves the marked files on disk.
Class_Terminate #
class-terminate
Clean up temporary files when the instance is destroyed
Signature:
Private Sub Class_Terminate()
The files KeepFile marked stay: the unfinished linelist of a failed build is saved here right before the instance is dropped.
ThrowError #
throw-error
Raise a typed project error
Signature:
Private Sub ThrowError(ByVal errNumber As ProjectError, ByVal message As String)
Parameters:
errNumber: ProjectError. The error code.message: String. Descriptive error message.
Used in (15 file(s))
- CodeTransfer.cls
- Linelist.cls
- LinelistSpecs.cls
- BuildSteps.bas
- EventsDesignerAdvanced.bas
- EventsDesignerMulti.bas
- HeadlessBuild.bas
- SetupRibbon.bas
- TestTemporaryRepos.bas
- TestHeadlessLinelistBuild.bas
- TestHelpersLite.bas
- TestCodeTransfer.bas
- TestLinelistRun.bas
- OBTProbeSandbox.bas
- TestSetupRibbon.bas