yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::util::PlatformPaths Class Reference

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.
 

Detailed Description

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.

Member Function Documentation

◆ GetHomeDirectory()

std::filesystem::path yaze::util::PlatformPaths::GetHomeDirectory ( )
static

Get the user's home directory in a cross-platform way.

  • Windows: Uses USERPROFILE environment variable
  • Unix/macOS: Uses HOME environment variable
  • Fallback: Returns current directory
Returns
Path to user's home directory, or "." if not available

Definition at line 23 of file platform_paths.cc.

Referenced by FindAsset(), and GetAppDataDirectory().

◆ GetAppDataDirectory()

absl::StatusOr< std::filesystem::path > yaze::util::PlatformPaths::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.

  • Windows: APPDATA%\yaze (e.g., C:\Users\user\AppData\Roaming\yaze)
  • macOS/Unix: ~/.yaze
Returns
StatusOr with path to the application data directory.

Definition at line 73 of file platform_paths.cc.

References EnsureDirectoryExists(), and GetHomeDirectory().

Referenced by GetAppDataSubdirectory(), and GetConfigDirectory().

Here is the call graph for this function:

◆ GetConfigDirectory()

absl::StatusOr< std::filesystem::path > yaze::util::PlatformPaths::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.

  • Windows: APPDATA%\yaze
  • macOS/Unix: ~/.yaze
Returns
StatusOr with path to the configuration directory.

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().

Here is the call graph for this function:

◆ GetAppDataSubdirectory()

absl::StatusOr< std::filesystem::path > yaze::util::PlatformPaths::GetAppDataSubdirectory ( const std::string &  subdir)
static

Get a subdirectory within the app data folder.

Creates the directory if it doesn't exist.

Parameters
subdirSubdirectory name (e.g., "agent", "cache", "logs")
Returns
StatusOr with path to subdirectory

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().

Here is the call graph for this function:

◆ EnsureDirectoryExists()

absl::Status yaze::util::PlatformPaths::EnsureDirectoryExists ( const std::filesystem::path &  path)
static

Ensure a directory exists, creating it if necessary.

Uses std::filesystem::create_directories which works cross-platform.

Parameters
pathDirectory path to create
Returns
OK if directory exists or was created successfully

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().

Here is the call graph for this function:

◆ Exists()

bool yaze::util::PlatformPaths::Exists ( const std::filesystem::path &  path)
static

Check if a file or directory exists.

Parameters
pathPath to check
Returns
true if exists, false otherwise

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().

◆ GetTempDirectory()

absl::StatusOr< std::filesystem::path > yaze::util::PlatformPaths::GetTempDirectory ( )
static

Get a temporary directory for the application.

  • Windows: TEMP%\yaze
  • Unix: /tmp/yaze or $TMPDIR/yaze
Returns
StatusOr with path to temp directory

Definition at line 152 of file platform_paths.cc.

References EnsureDirectoryExists().

Here is the call graph for this function:

◆ NormalizePathForDisplay()

std::string yaze::util::PlatformPaths::NormalizePathForDisplay ( const std::filesystem::path &  path)
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).

Parameters
pathPath to normalize
Returns
Normalized path string

Definition at line 171 of file platform_paths.cc.

◆ ToNativePath()

std::string yaze::util::PlatformPaths::ToNativePath ( const std::filesystem::path &  path)
static

Convert path to native format.

Ensures path uses the correct separator for the current platform.

Parameters
pathPath to convert
Returns
Native path string

Definition at line 179 of file platform_paths.cc.

◆ FindAsset()

absl::StatusOr< std::filesystem::path > yaze::util::PlatformPaths::FindAsset ( const std::string &  relative_path)
static

Find an asset file in multiple standard locations.

Searches for an asset file in the following order:

  1. YAZE_ASSETS_PATH (if defined at compile time) + relative_path
  2. Current working directory + assets/ + relative_path
  3. Executable directory + assets/ + relative_path
  4. Parent directory + assets/ + relative_path
  5. ~/.yaze/assets/ + relative_path (user-installed assets)
  6. /usr/local/share/yaze/assets/ + relative_path (system-wide on Unix)
Parameters
relative_pathPath relative to assets directory (e.g., "agent/prompt_catalogue.yaml")
Returns
StatusOr with absolute path to found asset file

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().

Here is the call graph for this function:

The documentation for this class was generated from the following files: