Table of Contents

Class IOUtility

Namespace
PdfSharp.Quality
Assembly
PdfSharp.Quality-gdi.dll

Static utility functions for file IO. These function are intended for unit test und sample in a solution code only.

public static class IOUtility
Inheritance
IOUtility
Inherited Members

Methods

EnsureAssets(string?, int?)

Ensures the assets folder exists in the solution root and an optional specified file or directory exists. If relativeFileOrDirectory is specified, it is considered to be a path to a directory if it ends with a directory separator. Otherwise, it is considered to ba a path to a file.

public static void EnsureAssets(string? relativeFileOrDirectory = null, int? requiredAssetsVersion = null)

Parameters

relativeFileOrDirectory string

A relative path to a file or directory.

requiredAssetsVersion int?

The minimum of the required assets version.

EnsureAssetsVersion(int)

Ensures the assets directory exists in the solution root and its version is at least the specified version.

public static void EnsureAssetsVersion(int requiredAssetsVersion)

Parameters

requiredAssetsVersion int

The minimum of the required assets version.

FindLatestTempFile(string?, string, string, bool)

Finds the latest temporary file in a directory. The pattern of the file is expected to be '{namePrefix}*_temp.{extension}'.

public static string? FindLatestTempFile(string? namePrefix, string path, string extension = "tmp", bool recursive = false)

Parameters

namePrefix string

The prefix of the file name to search for.

path string

The path to search in.

extension string

The file extension of the file.

recursive bool

If set to true subdirectories are included in the search.

Returns

string

GetAssetsPath(string?)

Gets the root path of the current assets directory if no parameter is specified, or null, if no assets directory exists in the solution root directory. If a parameter is specified gets the assets root path combined with the specified relative path or file. If only the root path is returned it always ends with a directory separator. If a parameter is specified the return value ends literally with value of the parameter.

public static string? GetAssetsPath(string? relativePathOrFileInAsset = null)

Parameters

relativePathOrFileInAsset string

Returns

string

GetSolutionRoot()

Gets the root path of the current solution, or null, if no parent directory with a solution file exists.

public static string? GetSolutionRoot()

Returns

string

GetTempFileName(string?, string?, bool)

Creates a temporary file name with the pattern '{namePrefix}-{WIN|WSL|LNX|...}-{...uuid...}_temp.{extension}'. The name ends with '_temp.' to make it easy to delete it using the pattern '*_temp.{extension}'. No file is created by this function. The name contains 10 hex characters to make it unique. It is not tested whether the file exists, because we have no path here.

public static string GetTempFileName(string? namePrefix, string? extension, bool addInfo = true)

Parameters

namePrefix string
extension string
addInfo bool

Returns

string

GetTempFullFileName(string?, string?, bool)

Creates a temporary file and returns the full name. The name pattern is '/.../temp/.../{namePrefix}-{WIN|WSL|LNX|...}-{...uuid...}_temp.{extension}'. The namePrefix may contain a sub-path relative to the temp directory. The name ends with '_temp.' to make it easy to delete it using the pattern '*_temp.{extension}'. The file is created and immediately closed. That ensures the returned full file name can be used.

public static string GetTempFullFileName(string? namePrefix, string? extension, bool addOS = true)

Parameters

namePrefix string
extension string
addOS bool

Returns

string

GetTempPath(string?)

Gets the root or sub path of the current temp directory. The directory is created if it does not exist. If a valid path is returned it always ends with the current directory separator.

public static string? GetTempPath(string? relativeDirectoryInTemp = null)

Parameters

relativeDirectoryInTemp string

Returns

string

GetViewerWatchDirectory()

Gets the viewer watch directory. Which is currently just a hard-coded directory on drive C or /mnt/c

public static string GetViewerWatchDirectory()

Returns

string

IsDirectorySeparator(char)

True if the given character is a directory separator.

public static bool IsDirectorySeparator(char ch)

Parameters

ch char

Returns

bool

NormalizeDirectorySeparators(ref string?)

Replaces all back-slashes with forward slashes in the specified path. The resulting path works under Windows and Linux if no drive names are included.

public static void NormalizeDirectorySeparators(ref string? path)

Parameters

path string