Interface PathCreator

All Known Implementing Classes:
DirectoryWithPrefix

public interface PathCreator
Converts file-paths between relative and absolute.
Author:
Owen Feehan
  • Method Details

    • makePathAbsolute

      Path makePathAbsolute(Optional<String> suffix, Optional<String> extension, String fallbackSuffix)
      Generates a full path, given the final part (suffix) of a path.

      All sub-directories are created if needed to ensure it's possible to write to the fullPath.

      Parameters:
      suffix - the final part of the path, to be added to the prefix
      extension - a file extension (without a leading period).
      fallbackSuffix - if neither a prefix is defined nor a suffix, then this provides a suffix to use so a file isn't only an extension.
      Returns:
      a complete absolute path with all components (prefix, suffix) etc., including the leading directory.
    • makePathRelative

      Path makePathRelative(Path suffix)
      Extracts a relative-file path, given the final part (suffix) of a path.

      The path will be relative to the underlying root directory.

      This relative-path includes any filename-prefix added by the DirectoryWithPrefix.

      Parameters:
      suffix - the final part of the path, to be added to the prefix
      Returns:
      a complete relative path with all components (prefix, suffix) etc., but no leading directory.