Class SettingsManager

java.lang.Object
net.vincent.communidirect.common.config.SettingsManager

public class SettingsManager extends Object
Loads and persists CommuniDirect settings from ~/.communidirect/config.toml. If the file (or its parent directory) does not exist it is created with built-in defaults. The log directory is also created if it is absent.
  • Constructor Details

    • SettingsManager

      public SettingsManager()
      Initialises all fields with their compiled-in defaults. Call load() to overlay values from ~/.communidirect/config.toml.
  • Method Details

    • load

      public void load()
      Loads configuration from disk. Creates the config file (and all required directories) with default values if it does not already exist.
    • resolveHome

      public static String resolveHome(String path)
      Expands a leading ~ to the current user's home directory.
      Parameters:
      path - the path string, possibly starting with ~
      Returns:
      the same path with ~ replaced by the user's home directory, or the original path if it does not start with ~
    • getPort

      public int getPort()
      Listening port (default 9833).
    • getIp

      public String getIp()
      Bind IP address (default "127.0.0.1").
    • getLogDir

      public String getLogDir()
      Absolute path to the log directory, with ~ expanded to the home directory.
    • getAccessLogName

      public String getAccessLogName()
      Filename (not path) for the access log (default "access.log").
    • getErrLogName

      public String getErrLogName()
      Filename (not path) for the error log (default "err.log").