Overview / System & concurrency

file

File and folder utilities, and a C file API with memory mapping and UTF-8 paths on both platforms.

Always compiled: part of the core build.Include #include <ethereal/cpp/file/file_inc.hpp>C layer

file_inc.hpp

#include <ethereal/cpp/file/file_inc.hpp>

io.hpp

#include <ethereal/cpp/file/io.hpp>
function

CheckUACLevel

Ethereal::IO#
ETL_INT32 CheckUACLevel( ETL_HANDLE hProcessHandle = ETL_HANDLE() ) noexcept;

Checks the permission level of the current process (UAC). Determines whether the current process is running with administrative privileges by querying the security token and the Windows User Account Control (UAC) policy. If a valid handle is provided, it will be used. Otherwise, the current process will be used.

*** Supported on Windows only.

hProcessHandle
Process handle to be verified (default: nullptr, uses the current process).
Operation result code: 0: Success - Process is running with elevated privileges (Administrator). 1: Failed to access the system registry (access denied or not found). 2: Failed to access the process token (insufficient permissions). 3: Failed to verify process privileges (insufficient permissions). 4: Failed to adjust process privileges (insufficient permissions).
function

OpenBrowserURL

Ethereal::IO#
ETL_UINT64 OpenBrowserURL( const char * sURL );

Opens a URL in the system's default browser. Uses the Windows API to launch the browser with the specified URL. Ideal for quick integrations with web systems, support, or external links.

*** Supported on Windows only.

sURL
Pointer to a string containing the URL to be opened (e.g., "https://example.com").
Operation result code: 0: Success. Other codes represent the resulting error from the @ShellExecuteW function.
function

CreatePath

Ethereal::IO#
ETL_DWORD CreatePath( const char * sDirectoryPath, const bool bFilterAlreadyExistErr = true );

Creates a directory (and all parent directories if necessary). Checks whether the path already exists and, if not, attempts to create it. Useful to ensure that directory structures are prepared before saving files.

sDirectoryPath
Full path of the directory to be created (e.g., "C:\\Logs\\2026\\July").
bFilterAlreadyExistErr
If true, ignores errors when the directory already exists (default: true).
Operation result code: 0: Success (or the directory already existed, with bFilterAlreadyExistErr). 1: Null or empty path. Otherwise the system error code: GetLastError() on Windows, errno on POSIX (ERROR_ALREADY_EXISTS / EEXIST when it already existed and the filter is off).
Windows, Linux and macOS share one implementation (std::filesystem). Before 2026-09-28 the POSIX version created nothing and reported success, and the Windows one created only the last level.
function

GetFileNameFromPath

Ethereal::IO#
std::string GetFileNameFromPath( const std::string & FilePath );

Extracts the file name from a full path. Removes preceding directories and returns only the file name with extension. Compatible with Windows (\\) and Unix (/) path formats.

FilePath
Full file path (e.g., "C:\\Projects\\Log.txt").
Returns the file name (e.g., "Log.txt"). If the path is empty, returns an empty string. If no directory separators are present, returns the input string.
function

GetAndFormatModuleNameToString

Ethereal::IO#
std::string GetAndFormatModuleNameToString( const ETL_HMODULE hModule );

Formats the current module name, returning only the file name without the path.

@std::string containing the current module name, without directories.
function

GetAndFormatModuleNameToCAString

Ethereal::IO#
String::CAString GetAndFormatModuleNameToCAString( const ETL_HMODULE hModule );

Formats the current module name, returning only the file name without the path.

@CAString containing the current module name, without directories.
function

GetAllFilesAtPath

Ethereal::IO#
bool GetAllFilesAtPath( const std::wstring & Path, std::vector<std::wstring> & vec_OutFiles );

Recursively retrieves all files from a directory. Adds the full paths of all discovered files to the output list. Does not perform filtering by extension.

Path
Base directory to be scanned (e.g., "D:\\Projects\\").
vec_OutFiles
Output vector that will store the full paths of the found files.
@true if the directory exists and is processed successfully. @false if the directory does not exist or is not accessible, or the library is not licensed.
function

GetAllFilesAtPathByExtension

Ethereal::IO#
bool GetAllFilesAtPathByExtension( const std::wstring & Path, std::vector<std::wstring> & vec_OutFiles, const std::vector< std::wstring > & vec_Extensions );

Recursively retrieves all files from a directory with specific extensions. Adds to the output vector only the files that match the provided extensions. The search is recursive and ignores files that do not meet the filter.

Path
Base directory to be scanned (e.g., "D:\\Projects\\").
vec_OutFiles
Output vector that will store the full paths of the found files.
vec_Extensions
List of valid extensions for filtering (e.g., {L".cpp", L".h"}). The dot must be included.
@true if the directory exists and is processed successfully. @false if the directory does not exist or is not accessible, or the library is not licensed.
function

DeleteAllFilesAtPath

Ethereal::IO#
std::size_t DeleteAllFilesAtPath( const std::wstring & Path );

Removes all files in a directory (recursively). Only files are removed. Subdirectories and their structure are preserved. Uses std::filesystem and ignores files without access permission.

Path
Base directory where files will be deleted (e.g., "C:\\Temp\\").
Returns the total number of files successfully deleted. '0' if the directory does not exist or contains no valid files.
function

DeleteAllFilesAtPathByExtension

Ethereal::IO#
std::size_t DeleteAllFilesAtPathByExtension( const std::wstring & Path, const std::vector< std::wstring > & vec_Extensions );

Removes files with specific extensions from a directory (recursively). Only files matching the provided extensions will be removed. Subdirectories and files outside the filter will be ignored.

Path
Base directory where files will be deleted (e.g., "C:\\Logs\\").
vec_Extensions
List of extensions to be removed (e.g., {L".log", L".tmp"}). The dot must be included.
Returns the total number of files successfully deleted. '0' if no files are deleted or the directory is not accessible.
function

CheckFileSignature

Ethereal::IO#
ETL_INT32 CheckFileSignature( const std::wstring & Path );

Checks whether a file has a valid digital signature recognized by Windows. Uses the WinVerifyTrust API to validate the embedded signature of the target file. The function can be used to verify whether the file is trusted or signed by official vendors.

*** Supported on Windows only.

Path
Full path of the file to be verified (e.g., "C:\\Program Files\\App.exe").
Returns a status code based on the internal enumeration: 0 = Valid signature; 1 = File is not signed; 2 = Invalid or corrupted signature; 3 = Signature explicitly untrusted; 4 = Signature rejected by system policy; 5 = Signature rejected by administrator or user policy; 6 = Generic error or verification failure.

system.hpp

#include <ethereal/cpp/file/system.hpp>
enum

etl_fs_open_flags

#
C++
typedef enum etl_fs_open_flags                       /// Enum of flags for open.
{
    ETL_FS_OPEN_READ      = 1u << 0,                 /// Opens for reading.
    ETL_FS_OPEN_WRITE     = 1u << 1,                 /// Opens for writing.
    ETL_FS_OPEN_CREATE    = 1u << 2,                 /// Creates the file if it does not exist.
    ETL_FS_OPEN_TRUNC     = 1u << 3,                 /// Truncates the file on open (if write).
    ETL_FS_OPEN_APPEND    = 1u << 4,                 /// Always writes at the end.
    ETL_FS_OPEN_SEQ_HINT  = 1u << 5,                 /// Hint: sequential access (optimizations).
    ETL_FS_OPEN_RAND_HINT = 1u << 6                  /// Hint: random access (optimizations).
} etl_fs_open_flags;                                 /// Type name.
enum

etl_fs_result

#
C++
typedef enum etl_fs_result                           /// Enum with the result of the operations.
{
    ETL_FS_OK = 0,                                   /// Operation ok.
    ETL_FS_ERR_INVALID,                              /// Invalid parameter.
    ETL_FS_ERR_OPEN,                                 /// Failed to open.
    ETL_FS_ERR_IO,                                   /// IO failure (read/write/flush).
    ETL_FS_ERR_SEEK,                                 /// Seek failure.
    ETL_FS_ERR_MAP,                                  /// mmap/MapViewOfFile failure.
    ETL_FS_ERR_NOMEM,                                /// Failure due to lack of memory (when applicable).
    ETL_FS_ERR_NOTSUP,                               /// Not supported on this platform/mode.
    ETL_FS_ERR_NOT_LICENSED                          /// Refused: no license was accepted and the evaluation of this machine has ended, or the license passed was refused (see Bundle::UnlockBundle).
} etl_fs_result;                                     /// Type name.
struct

etl_fs_file

#
C++
typedef struct etl_fs_file                           /// File handle structure.
{
#if ETL_FS_WINDOWS                                   /// If Windows...
    void*    hFile;                                  /// File HANDLE (void* to avoid including windows.h here).
    void*    hMap;                                   /// Reserved: 'etl_fs_map_ro' closes the mapping handle right away (the view keeps it alive).
#else                                                /// If POSIX...
    ETL_INT32      fd;                                     /// File descriptor.
#endif                                               /// End.
    uint64_t size_cached;                            /// Optional size cache (may be 0 if unknown).
    uint32_t flags;                                  /// Open flags.
    uint32_t reserved;                               /// Padding/reserve for future alignment.
} etl_fs_file;                                       /// Type name.
function

etl_fs_open

#
etl_fs_result etl_fs_open( etl_fs_file* f, const char* path, uint32_t flags );
function

etl_fs_close

#
etl_fs_result etl_fs_close( etl_fs_file* f );
function

etl_fs_read

#
etl_fs_result etl_fs_read( etl_fs_file* f, void* out, size_t bytes, size_t* read_bytes );
function

etl_fs_write

#
etl_fs_result etl_fs_write( etl_fs_file* f, const void* data, size_t bytes, size_t* written_bytes );
function

etl_fs_size

#
etl_fs_result etl_fs_size( etl_fs_file* f, uint64_t* out_size );
function

etl_fs_seek

#
etl_fs_result etl_fs_seek( etl_fs_file* f, int64_t offset, ETL_INT32 origin );
function

etl_fs_flush

#
etl_fs_result etl_fs_flush( etl_fs_file* f );
struct

etl_fs_map

#
C++
typedef struct etl_fs_map                            /// Mapped view structure.
{
    void*    data;                                   /// Pointer to the mapped memory.
    uint64_t size;                                   /// Mapped size.
#if ETL_FS_WINDOWS                                   /// If Windows...
    void*    view;                                   /// View pointer (may be equal to data).
#endif                                               /// End.
} etl_fs_map;                                        /// Type name.
function

etl_fs_map_ro

#
etl_fs_result etl_fs_map_ro( etl_fs_file* f, etl_fs_map* out_map );
function

etl_fs_unmap

#
etl_fs_result etl_fs_unmap( etl_fs_file* f, etl_fs_map* map );
function

etl_fs_read_all

#
etl_fs_result etl_fs_read_all( const char* path, void* out, size_t cap, size_t* out_bytes );
function

CheckUACLevel

Ethereal::FileSystem#
ETL_INT32 CheckUACLevel( ETL_HANDLE hProcessHandle = ETL_HANDLE() ) noexcept;

Checks the permission level of the current process (UAC). Determines whether the current process runs with administrative privileges, by querying the security token and the Windows User Account Control (UAC) policy. If a valid handle is given, it is used. Otherwise, the current process is used.

hProcessHandle
Process 'handle' to check (default: nullptr, uses the current process).
Result code of the operation: 0: Success. The process has elevated privileges (Administrator). 1: Failed to access the system registry (access denied or missing). 2: Failed to access the process token (insufficient permissions). 3: Failed to check the process privileges (insufficient permissions). 4: Failed to adjust the process privileges (insufficient permissions).
ETL_HANDLE instead of HANDLE, and the default is the value initialized type instead of 'nullptr': on POSIX a descriptor is an integer and does not accept nullptr.