Skip to main content

Overview

The files utility manages the SDK’s configuration file system, providing access to the working directory and file enumeration capabilities. Files are stored in the user’s Documents folder under .hw/settings/.

Usage

Access the global file manager instance:
#include "utils/files/files.h"

// Use the global instance
g_files.refresh();

Global Instance

g_files
files::impl
Global singleton instance of the file management utility

Class: files::impl

Properties

fs_path
std::filesystem::path
The filesystem path to the settings directory. Automatically set to %USERPROFILE%\Documents\.hw\settings
info.file_names
std::deque<std::string>
Collection of configuration file names found in the settings directory (populated by refresh())
info.variables
std::vector<config::option>
Vector of configuration options loaded from files

Methods

get_working_path

Retrieves the SDK’s working directory path in the user’s Documents folder.
return
std::filesystem::path
Path to %USERPROFILE%\Documents\.hw
auto working_path = g_files.get_working_path();
// Returns: C:\Users\Username\Documents\.hw

refresh

Scans the settings directory and populates the file_names collection with all .hw configuration files.
g_files.refresh();

// Access discovered files
for (const auto& filename : g_files.info.file_names) {
    // Process each .hw file
}

Complete Example

#include "utils/files/files.h"
#include <iostream>

void list_config_files()
{
    // Refresh the file list from disk
    g_files.refresh();
    
    // Get the settings path
    std::cout << "Settings directory: " << g_files.fs_path << std::endl;
    
    // Iterate through discovered configuration files
    std::cout << "Found " << g_files.info.file_names.size() << " config files:" << std::endl;
    
    for (const auto& file : g_files.info.file_names) {
        std::cout << "  - " << file << std::endl;
    }
}

void get_full_path_example()
{
    auto working_path = g_files.get_working_path();
    auto settings_path = g_files.fs_path;
    
    std::cout << "Working path: " << working_path << std::endl;
    std::cout << "Settings path: " << settings_path << std::endl;
    
    // Example output:
    // Working path: C:\Users\Username\Documents\.hw
    // Settings path: C:\Users\Username\Documents\.hw\settings
}

File Structure

%USERPROFILE%\Documents\.hw\           (working path)
└── settings\                          (fs_path)
    ├── default.hw
    ├── competitive.hw
    └── custom.hw
The refresh() method only scans for files with the .hw extension. Other files in the directory are ignored.
Always call refresh() before accessing info.file_names to ensure the file list is up-to-date with the filesystem state.

Build docs developers (and LLMs) love