Cross-platform utilities for file system paths. More...
#include <platform_paths.h>
Static Public Member Functions | |
static std::filesystem::path | GetHomeDirectory () |
Get the user's home directory in a cross-platform way. | |
static absl::StatusOr< std::filesystem::path > | GetAppDataDirectory () |
Get the user-specific application data directory for YAZE. | |
static absl::StatusOr< std::filesystem::path > | GetConfigDirectory () |
Get the user-specific configuration directory for YAZE. | |
static absl::StatusOr< std::filesystem::path > | GetAppDataSubdirectory (const std::string &subdir) |
Get a subdirectory within the app data folder. | |
static absl::Status | EnsureDirectoryExists (const std::filesystem::path &path) |
Ensure a directory exists, creating it if necessary. | |
static bool | Exists (const std::filesystem::path &path) |
Check if a file or directory exists. | |
static absl::StatusOr< std::filesystem::path > | GetTempDirectory () |
Get a temporary directory for the application. | |
static std::string | NormalizePathForDisplay (const std::filesystem::path &path) |
Normalize path separators for display. | |
static std::string | ToNativePath (const std::filesystem::path &path) |
Convert path to native format. | |
static absl::StatusOr< std::filesystem::path > | FindAsset (const std::string &relative_path) |
Find an asset file in multiple standard locations. | |
Cross-platform utilities for file system paths.
Provides consistent, platform-independent file and directory operations that work correctly on Windows (MSVC), macOS, and Linux.
Definition at line 18 of file platform_paths.h.
|
static |
Get the user's home directory in a cross-platform way.
Definition at line 23 of file platform_paths.cc.
Referenced by FindAsset(), and GetAppDataDirectory().
|
static |
Get the user-specific application data directory for YAZE.
This is the standard location for storing user-specific data, settings, and cache files. The directory is created if it doesn't exist.
APPDATA%\yaze
(e.g., C:\Users\user\AppData\Roaming\yaze)~/.yaze
Definition at line 73 of file platform_paths.cc.
References EnsureDirectoryExists(), and GetHomeDirectory().
Referenced by GetAppDataSubdirectory(), and GetConfigDirectory().
|
static |
Get the user-specific configuration directory for YAZE.
This is the standard location for storing user configuration files. The directory is created if it doesn't exist.
APPDATA%\yaze
~/.yaze
Definition at line 105 of file platform_paths.cc.
References GetAppDataDirectory().
Referenced by yaze::core::RecentFilesManager::GetFilePath(), yaze::editor::AgentEditor::GetProfilesDirectory(), yaze::gui::ThemeManager::GetThemeSearchPaths(), yaze::util::LoadFileFromConfigDir(), yaze::editor::WorkspaceManager::RefreshPresets(), anonymous_namespace{agent_chat_widget.cc}::ResolveHistoryPath(), yaze::core::RecentFilesManager::Save(), yaze::util::SaveFile(), yaze::editor::AgentCollaborationCoordinator::SessionsDirectory(), and yaze::editor::UserSettings::UserSettings().
|
static |
Get a subdirectory within the app data folder.
Creates the directory if it doesn't exist.
subdir | Subdirectory name (e.g., "agent", "cache", "logs") |
Definition at line 111 of file platform_paths.cc.
References EnsureDirectoryExists(), and GetAppDataDirectory().
Referenced by yaze::cli::agent::LearnedKnowledgeService::LearnedKnowledgeService(), and yaze::cli::agent::TodoManager::TodoManager().
|
static |
Ensure a directory exists, creating it if necessary.
Uses std::filesystem::create_directories which works cross-platform.
path | Directory path to create |
Definition at line 128 of file platform_paths.cc.
References Exists().
Referenced by GetAppDataDirectory(), GetAppDataSubdirectory(), GetTempDirectory(), yaze::cli::agent::LearnedKnowledgeService::Initialize(), and yaze::cli::agent::TodoManager::Initialize().
|
static |
Check if a file or directory exists.
path | Path to check |
Definition at line 146 of file platform_paths.cc.
Referenced by EnsureDirectoryExists(), yaze::cli::agent::anonymous_namespace{learned_knowledge_service.cc}::FileExists(), and yaze::cli::agent::TodoManager::Initialize().
|
static |
Get a temporary directory for the application.
Definition at line 152 of file platform_paths.cc.
References EnsureDirectoryExists().
|
static |
Normalize path separators for display.
Converts all path separators to forward slashes for consistent output in logs and UI (forward slashes work on all platforms).
path | Path to normalize |
Definition at line 171 of file platform_paths.cc.
|
static |
Convert path to native format.
Ensures path uses the correct separator for the current platform.
path | Path to convert |
Definition at line 179 of file platform_paths.cc.
|
static |
Find an asset file in multiple standard locations.
Searches for an asset file in the following order:
relative_path | Path relative to assets directory (e.g., "agent/prompt_catalogue.yaml") |
Definition at line 184 of file platform_paths.cc.
References GetHomeDirectory().
Referenced by yaze::cli::PromptBuilder::BuildConstraintsSection(), yaze::cli::GeminiAIService::BuildFunctionCallSchemas(), yaze::cli::GeminiAIService::GeminiAIService(), and yaze::cli::PromptBuilder::ResolveCataloguePath().