/* File: FileHelper.h Description: Provides utility functions for loading and saving records from and to CSV-like text files. Ensures files are created if missing and supports simple record persistence. Author: Trenser Date: 22-May-2026 */ #pragma once #include #include #include #include #include "Vector.h" namespace util { /* Function: ensureDirectoryExists Description: Creates all missing directories present in the given file path. Iteratively parses the path and creates each directory level using _mkdir() before file operations are performed. Parameters: - filePath: const std::string&, relative or absolute file path Returns: - void Throws: - None (_mkdir failures are intentionally ignored if directory already exists) */ inline void ensureDirectoryExists(const std::string& filePath) { size_t position = 0; while ((position = filePath.find('/', position)) != std::string::npos) { std::string directory = filePath.substr(0, position); if (!directory.empty()) { (void)_mkdir(directory.c_str()); } position++; } } }