Class PathResolver

java.lang.Object
be.kuleuven.cs.distrinet.sparta.cli.PathResolver

public final class PathResolver extends Object
Small pure helper for resolving user-supplied model/output paths. Splitting this out of the CLI/CI bootstrap keeps the path handling unit-testable and avoids the fragile user.dir + "/" + target concatenation that mishandles absolute paths and platform separators.
  • Method Details

    • resolve

      public static File resolve(String baseDir, String target)
      Resolve a possibly-relative target against baseDir. If target is already absolute it is returned unchanged (the base dir is ignored); otherwise it is resolved as a child of baseDir. Platform separators are handled by File.
      Parameters:
      baseDir - the base directory (typically user.dir)
      target - the user-supplied path
      Returns:
      the resolved file
    • toFileURI

      public static URI toFileURI(String baseDir, String target)
      Resolve target against baseDir and turn the result into an EMF file URI. Uses URI.createFileURI(String) on the absolute path so separators and drive letters are encoded correctly.
      Parameters:
      baseDir - the base directory (typically user.dir)
      target - the user-supplied path
      Returns:
      the file URI for the resolved path