Class FsdUtils

java.lang.Object
org.jdrupes.vmoperator.util.FsdUtils

public class FsdUtils extends Object
Utilities to access configurable file system directories.

Based on the FHS and the XDG Base Directory Specification.

  • Constructor Details

  • Method Details

    • addUser

      public static Path addUser(Path path)
      Adds a directory with the user’s name to the path.

      If such a directory does not exist yet, creates it. If this file or the directory is not writable, return the given path.

      Parameters:
      path - the path
      Returns:
      the path
    • tmpDir

      public static Path tmpDir()
      Returns the directory for temporary storage.
      Returns:
      the path
    • userHome

      public static Path userHome()
      Returns the real home directory of the user or, if not available, a sub directory in tmpDir() with the user’s name.
      Returns:
      the path
    • dataHome

      public static Path dataHome(String appName)
      Returns the data home.
      Parameters:
      appName - the application name
      Returns:
      the path
    • configHome

      public static Path configHome(String appName)
      Returns the config home.
      Parameters:
      appName - the application name
      Returns:
      the path
    • stateHome

      public static Path stateHome(String appName)
      Returns the state directory.
      Parameters:
      appName - the application name
      Returns:
      the path
    • runtimeDir

      public static Path runtimeDir(String appName)
      Returns the runtime directory.
      Parameters:
      appName - the application name
      Returns:
      the path
    • findConfigFile

      public static Optional<Path> findConfigFile(String appName, String filename)
      Find a configuration file.

      The given filename is searched for in:

      1. the current working directory,
      2. the configHome(String)
      3. the subdirectory appName of /etc/opt
      4. the subdirectory appName of /etc
      Parameters:
      appName - the application name
      filename - the filename
      Returns:
      the optional