Package org.jdrupes.vmoperator.util
Class FsdUtils
java.lang.Object
org.jdrupes.vmoperator.util.FsdUtils
Utilities to access configurable file system directories.
Based on the FHS and the XDG Base Directory Specification.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Path
Adds a directory with the user’s name to the path.static Path
configHome
(String appName) Returns the config home.static Path
Returns the data home.findConfigFile
(String appName, String filename) Find a configuration file.static Path
runtimeDir
(String appName) Returns the runtime directory.static Path
Returns the state directory.static Path
tmpDir()
Returns the directory for temporary storage.static Path
userHome()
Returns the real home directory of the user or, if not available, a sub directory intmpDir()
with the user’s name.
-
Constructor Details
-
FsdUtils
public FsdUtils()
-
-
Method Details
-
addUser
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
Returns the directory for temporary storage.- Returns:
- the path
-
userHome
Returns the real home directory of the user or, if not available, a sub directory intmpDir()
with the user’s name.- Returns:
- the path
-
dataHome
Returns the data home.- Parameters:
appName
- the application name- Returns:
- the path
-
configHome
Returns the config home.- Parameters:
appName
- the application name- Returns:
- the path
-
stateHome
Returns the state directory.- Parameters:
appName
- the application name- Returns:
- the path
-
runtimeDir
Returns the runtime directory.- Parameters:
appName
- the application name- Returns:
- the path
-
findConfigFile
Find a configuration file.The given filename is searched for in:
- the current working directory,
- the
configHome(String)
- the subdirectory
appName
of/etc/opt
- the subdirectory
appName
of/etc
- Parameters:
appName
- the application namefilename
- the filename- Returns:
- the optional
-