private final int hashCode;
public JcrPath(JcrFileSystem filesSystem, String path) {
- // this(filesSystem, path.equals("/") ? null : path.split("/"), path ==
- // null ? true : path.startsWith("/"));
this.fs = filesSystem;
if (path == null)
throw new JcrFsException("Path cannot be null");
this.hashCode = "".hashCode();
return;
}
+
+ if (path.equals("~")) {// home
+ path = filesSystem.getUserHomePath();
+ if (path == null)
+ throw new JcrFsException("No home directory available");
+ }
+
this.absolute = path.charAt(0) == delimChar ? true : false;
String trimmedPath = path.substring(absolute ? 1 : 0,
path.charAt(path.length() - 1) == delimChar ? path.length() - 1 : path.length());
if (other.startsWith(this)) {
String p1 = toString();
String p2 = other.toString();
- return new JcrPath(fs, p2.substring(p1.length(), p2.length()));
+ String relative = p2.substring(p1.length(), p2.length());
+ if (relative.charAt(0) == '/')
+ relative = relative.substring(1);
+ return new JcrPath(fs, relative);
}
- throw new IllegalArgumentException(other + " cannot be realtivized against " + this);
+ throw new IllegalArgumentException(other + " cannot be relativized against " + this);
}
@Override
public URI toUri() {
try {
- return new URI("jcr", toString(), null);
+ return new URI(fs.provider().getScheme(), toString(), null);
} catch (URISyntaxException e) {
throw new JcrFsException("Cannot create URI for " + toString(), e);
}