Package com.qulice.spi
Class Relative
java.lang.Object
com.qulice.spi.Relative
Path of a file relative to a base directory.
Given a base directory and a target file, computes the file path
relative to the base, prefixed with a forward slash and using forward
slashes as separators. Uses Path.relativize(Path) after
normalising both paths to absolute form, which correctly handles cases
where the file and base dir share a canonical location but differ in
string form (for example, on macOS the /var symlink to
/private/var). When the file lies outside the base directory,
returns the file's absolute path unchanged.
- Since:
- 0.24
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Relative
Ctor.- Parameters:
base- Base directorytarget- Target file
-
-
Method Details
-
path
Path of the target file relative to the base directory.- Returns:
- Relative path starting with a forward slash, or the absolute path of the file if it is not under the base directory
-