Table of Contents

Class PathHelper

Namespace
RadioExt_Helper.utility
Assembly
RadioExt-Helper.dll
Helper class to get the various paths associated with the game and provides some helper methods for working with paths.
public static class PathHelper
Inheritance
PathHelper
Inherited Members

Methods

ClearDirectory(string)

Clear all files and folders from the specified directory.
public static void ClearDirectory(string directoryPath)

Parameters

directoryPath string
The path to the directory clear.

ContainsOodleDll(string?)

Check if the specified base path contains the Oodle DLL used for compression of game files.

This DLL is used by WolvenKit and may cause problems with icon generation if it's missing.

public static (bool exists, string? filePath) ContainsOodleDll(string? basePath)

Parameters

basePath string
The base path to check.

Returns

(bool exists, string filePath)
A tuple containing whether the DLL exists and the full path of the file that was found. If the DLL did not exist, the filePath is null.

ConvertToBitmap(Image<Rgba32>?)

Convert a SixLabors.ImageSharp.Image to a Bitmap.
public static Bitmap ConvertToBitmap(Image<Rgba32>? image)

Parameters

image Image<Rgba32>
The SixLabors.ImageSharp.Image to convert.

Returns

Bitmap
If image is null, returns the default missing image; otherwise, returns a Bitmap representing the SixLabors.ImageSharp.Image.

DownloadFileAsync(string, string)

Download a file from the specified URL to the specified destination file path.
public static Task DownloadFileAsync(string fileUrl, string destinationFilePath)

Parameters

fileUrl string
The URL of the file to download.
destinationFilePath string
The path to save the file on disk, including file name.

Returns

Task
A task that represents the current async operation.

DownloadImageAsync(string)

Download an image from the specified URL and convert it to a Bitmap.
public static Task<Bitmap> DownloadImageAsync(string imageUrl)

Parameters

imageUrl string
The URL of the image to download.

Returns

Task<Bitmap>
A task, that when completed, contains the downloaded image as a bitmap or the default missing image if the image could not be downloaded.

ExtractZipFileAsync(string, string)

Extract a .zip file to the specified destination directory.
public static Task ExtractZipFileAsync(string zipFilePath, string destinationDirectory)

Parameters

zipFilePath string
The fully qualified path to a .zip file.
destinationDirectory string
The directory to extract the contents of the .zip file into.

Returns

Task

Exceptions

ArgumentNullException
If the zipFilePath or the destinationDirectory is null or empty.
FileNotFoundException
If the zipFilePath did not exist on the filesystem.

GetAlwaysForbiddenPaths()

Get the list of always forbidden paths as a list of ForbiddenKeyword objects. These paths are the system directories and program files directories.
public static List<ForbiddenKeyword> GetAlwaysForbiddenPaths()

Returns

List<ForbiddenKeyword>
A list of ForbiddenKeyword objects defining the path.

GetGamePath()

Retrieves the base game path (the folder containing bin) from the Cyberpunk 2077 executable by showing a file dialog.
public static string GetGamePath()

Returns

string
The base path of the game or Empty if path couldn't be determined.

GetGamePath(bool)

Retrieves the base game path (the folder containing bin) from the Cyberpunk 2077 executable. Optionally, indicate if the dialog should loop until a valid file is selected.
public static string GetGamePath(bool shouldLoop)

Parameters

shouldLoop bool
Indicates whether the file dialog should continue showing until a valid file is selected.

Returns

string
The base path of the game or Empty if path couldn't be determined.

GetRadioExtPath(string)

Checks for and retrieves (if it exists) the path to the radioExt folder where custom radios are placed.
public static string GetRadioExtPath(string gameBasePath)

Parameters

gameBasePath string

Returns

string
The path to the radioExt folder, or Empty if the path couldn't be determined.

GetRadiosPath(string)

Get the path to the radios folder under the radioExt mod folder. This method does not check if the path exists.
public static string GetRadiosPath(string gameBasePath)

Parameters

gameBasePath string
The base path of the game.

Returns

string
The path to the radios folder, based on the base path of the game.

GetRelativePath(string, string)

Get a relative path to the fullPath from the stagingPath.
public static string GetRelativePath(string fullPath, string stagingPath)

Parameters

fullPath string
The full path.
stagingPath string
The path to the staging folder.

Returns

string

GetStagingPath()

Retrieves the staging path (the folder containing radio stations before copied to the game) by showing a folder dialog.
public static string GetStagingPath()

Returns

string
The base path of the game or Empty if path couldn't be determined.

GetStagingPath(bool)

Retrieves the staging path (the folder containing radio stations before copied to the game). Optionally, indicate if the dialog should loop until a valid file is selected.
public static string GetStagingPath(bool shouldLoop)

Parameters

shouldLoop bool
Indicates whether the file dialog should continue showing until a valid file is selected.

Returns

string
The base path of the game or Empty if path couldn't be determined.

GrantAccess(string)

Grant's access to the path specified by the filepath. Used mainly for accessing the log folder and reading the log file.
public static void GrantAccess(string filePath)

Parameters

filePath string
The path to grant access on.

IsForbiddenPath(string)

Checks if the specified path is a forbidden path and thus invalid for the staging folder (or other purposes).
public static ForbiddenPathResult IsForbiddenPath(string stagingPath)

Parameters

stagingPath string
The proposed staging path.

Returns

ForbiddenPathResult
A ForbiddenPathResult specifying the reason why the path was forbidden or not.

IsSubPath(string, string)

Determines if a path is a sub-path (i.e., starts with) of another path.
public static bool IsSubPath(string basePath, string subPath)

Parameters

basePath string
The base path to check against.
subPath string
The path to check against the base path.

Returns

bool
true if the sub path is part of the base path; false otherwise or if an error occured.

IsValidArchiveFile(string)

Get a value indicating whether the specified file is a valid archive file based on the extension and ValidArchiveFiles.
public static bool IsValidArchiveFile(string filePath)

Parameters

filePath string
The path to the file to check.

Returns

bool
true if the file is a valid archive file; false otherwise.

IsValidAudioFile(string)

Get a value indicating whether the specified file is a valid audio file based on the extension and ValidAudioFiles.
public static bool IsValidAudioFile(string filePath)

Parameters

filePath string
The path to the file to check.

Returns

bool
true if the file is a valid audio file; false otherwise.

IsValidImageFile(string)

Get a value indicating whether the specified file is a valid image file based on the extension and ValidImageFiles.
public static bool IsValidImageFile(string filePath)

Parameters

filePath string
The path to the file to check.

Returns

bool
true if the file is a valid image file; false otherwise.

SanitizePath(string)

Replaces invalid path characters and specific characters (like the apostrophe (') which can causing issues with pathing.
public static string SanitizePath(string path)

Parameters

path string
The path to sanitize.

Returns

string
The sanitized path.