public static void copyTree(File src, File dst, Path prefix, PathFilter filter) throws IOException { if (!prefix.isAbsolute()) { prefix = prefix.makeAbsolute(); } int rootIndex = src.getPath().length() + 1; for (File file : src.listFiles()) { copyTree(rootIndex, file, new File(dst, file.getName()), prefix, filter); } }
@Override public ScriptFile getFile(String path) { int len = path.length(); if (len == 0) { return null; } char c = path.charAt(0); if (c == '.') { // avoid getting files outside the web root path = new Path(path).makeAbsolute().toString(); } else if (c != '/') {// avoid doing duplicate entries in document stack // cache path = new StringBuilder(len + 1).append("/").append(path).toString(); } try { return findFile(new Path(path).makeAbsolute().toString()); } catch (IOException e) { throw new NuxeoException(e); } }
} else { log.warn("Relative path used but there is any running script"); path = new Path(path).makeAbsolute().toString();
public Path append(Path tail) { // optimize some easy cases if (tail == null || tail.segmentCount() == 0) { return this; } if (isEmpty()) { return tail.makeRelative(); } if (isRoot()) { return tail.makeAbsolute(); } // concatenate the two segment arrays int myLen = segments.length; int tailLen = tail.segmentCount(); String[] newSegments = new String[myLen + tailLen]; System.arraycopy(segments, 0, newSegments, 0, myLen); for (int i = 0; i < tailLen; i++) { newSegments[myLen + i] = tail.segment(i); } // use my leading separators and the tail's trailing separator Path result = new Path(newSegments, (separators & HAS_LEADING) | (tail.hasTrailingSeparator() ? HAS_TRAILING : 0)); String tailFirstSegment = newSegments[myLen]; if (tailFirstSegment.equals("..") || tailFirstSegment.equals(".")) { //$NON-NLS-1$ //$NON-NLS-2$ result.canonicalize(); } return result; }