Class SavantPaths

java.lang.Object
org.savantbuild.util.SavantPaths

public class SavantPaths extends Object
Resolves Savant directory paths using XDG Base Directory conventions and handles migration from the legacy ~/.savant/ directory layout.

XDG mapping:

  • Cache → $XDG_CACHE_HOME/savant (default ~/.cache/savant)
  • Config → $XDG_CONFIG_HOME/savant (default ~/.config/savant)
  • Method Details

    • get

      public static SavantPaths get()
      Returns the default singleton instance that uses the real home directory and environment.
      Returns:
      The default SavantPaths instance.
    • cacheDir

      public Path cacheDir()
      Returns:
      The Savant cache directory: $XDG_CACHE_HOME/savant or ~/.cache/savant
    • configDir

      public Path configDir()
      Returns:
      The Savant config directory: $XDG_CONFIG_HOME/savant or ~/.config/savant
    • migrate

      public void migrate(Output output)
      Migrates from the legacy ~/.savant/ directory to XDG locations. This method is idempotent — it only runs once per instance.

      Migration rules:

      • If XDG dirs exist AND ~/.savant exists → warn that ~/.savant is being ignored
      • If XDG dirs don't exist AND ~/.savant exists → move contents to XDG locations
      • If neither exists → no-op (fresh install)
      Parameters:
      output - The output for printing migration messages.