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
Global singleton instance of the file management utility
Class: files::impl
Properties
The filesystem path to the settings directory. Automatically set to %USERPROFILE%\Documents\.hw\settings
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.
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
Directory Layout
Accessing Files
%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.