Class PDJE_Name_Sanitizer

Class Documentation

class PDJE_Name_Sanitizer

A utility class for sanitizing and de-sanitizing file names.

This class provides static methods to encode and decode file names using a URL-safe base64 encoding. This is useful for ensuring that file names do not contain characters that are incompatible with the file system.

Public Functions

PDJE_Name_Sanitizer() = delete
~PDJE_Name_Sanitizer() = delete

Public Static Functions

static std::optional<SANITIZED> sanitizeFileName(const std::string &fileName)

Sanitizes a file name using base64 URL-unpadded encoding.

Parameters:

fileName – The file name to sanitize.

Returns:

An optional containing the sanitized file name, or std::nullopt if an error occurs.

static std::string getFileName(const SANITIZED &sanitized)

De-sanitizes a file name that was sanitized with sanitizeFileName.

Parameters:

sanitized – The sanitized file name.

Returns:

The original, de-sanitized file name.