+ public String mapHostPath(String s) { return mapHostPath(new File(s)); }
+ public String mapHostPath(File f) {
+ MP[] list;
+ FS root;
+ synchronized(this) { mps = this.mps; root = this.root; }
+ if(!f.isAbsolute()) f = new File(f.getAbsolutePath());
+ for(int i=mps.length;i>=0;i--) {
+ FS fs = i == mps.length ? root : mps[i].fs;
+ String path = i == mps.length ? "" : mps[i].path;
+ if(!(fs instanceof HostFS)) continue;
+ File fsroot = ((HostFS)fs).getRoot();
+ if(!fsroot.isAbsolute()) fsroot = new File(fsroot.getAbsolutePath());
+ if(f.getPath().startsWith(fsroot.getPath())) {
+ char sep = File.separatorChar;
+ String child = f.getPath().substring(fsroot.getPath().length());
+ if(sep != '/') {
+ char[] child_ = child.toCharArray();
+ for(int j=0;j<child_.length;j++) {
+ if(child_[j] == '/') child_[j] = sep;
+ else if(child_[j] == sep) child_[j] = '/';
+ }
+ child = new String(child_);
+ }
+ String mapped = "/" + (path.length()==0?"":path+"/") + child;
+ return mapped;
+ }
+ }
+ return null;
+ }
+