
com.undefinedlabs.scope.utils.PathUtils Maven / Gradle / Ivy
package com.undefinedlabs.scope.utils;
public enum PathUtils {
INSTANCE;
public String expandTilde(final String path) {
if (StringUtils.isEmpty(path) || !path.startsWith("~")) {
return path;
}
if (!path.equals("~") && !path.startsWith("~/")) {
throw new UnsupportedOperationException(
"Home dir expansion for other user is not supported.");
}
return path.replaceFirst("^~", getUserHome());
}
protected String getUserHome() {
return System.getProperty("user.home");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy