/** * @param path * @param host * @return String */ private String getPath(IPath path, String host) { IPath newPath = path; // They are potentially for only Windows operating system. // a.) if path has a device, and if it begins with IPath.SEPARATOR, // remove it final String device = path.getDevice(); if ((device != null) && (device.length() > 0)) { if (device.charAt(0) == IPath.SEPARATOR) { final String newDevice = device.substring(1); newPath = path.setDevice(newDevice); } } // b.) if it has a hostname, it is UNC name... Any java or eclipse api // helps it ?? if (path != null && host != null && host.length() != 0) { IPath uncPath = new Path(host); uncPath = uncPath.append(path); newPath = uncPath.makeUNC(true); } return newPath.toString(); }
public IPath append(IPath tail) { //optimize some easy cases if (tail == null || tail.segmentCount() == 0) return this; //these call chains look expensive, but in most cases they are no-ops if (this.isEmpty()) return tail.setDevice(device).makeRelative().makeUNC(isUNC()); if (this.isRoot()) return tail.setDevice(device).makeAbsolute().makeUNC(isUNC()); //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(device, newSegments, (separators & (HAS_LEADING | IS_UNC)) | (tail.hasTrailingSeparator() ? HAS_TRAILING : 0)); String tailFirstSegment = newSegments[myLen]; if (tailFirstSegment.equals("..") || tailFirstSegment.equals(".")) { //$NON-NLS-1$ //$NON-NLS-2$ result.canonicalize(); } return result; }
public IPath append(IPath tail) { //optimize some easy cases if (tail == null || tail.segmentCount() == 0) return this; //these call chains look expensive, but in most cases they are no-ops if (this.isEmpty()) return tail.setDevice(device).makeRelative().makeUNC(isUNC()); if (this.isRoot()) return tail.setDevice(device).makeAbsolute().makeUNC(isUNC()); //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(device, newSegments, (separators & (HAS_LEADING | IS_UNC)) | (tail.hasTrailingSeparator() ? HAS_TRAILING : 0)); String tailFirstSegment = newSegments[myLen]; if (tailFirstSegment.equals("..") || tailFirstSegment.equals(".")) { //$NON-NLS-1$ //$NON-NLS-2$ result.canonicalize(); } return result; }
@Override public IPath append(IPath tail) { //optimize some easy cases if (tail == null || tail.segmentCount() == 0) return this; //these call chains look expensive, but in most cases they are no-ops //the tail must be for the same platform as this instance if (this.isEmpty() && ((flags & IS_FOR_WINDOWS) == 0) == tail.isValidSegment(":")) //$NON-NLS-1$ return tail.setDevice(device).makeRelative().makeUNC(isUNC()); if (this.isRoot() && ((flags & IS_FOR_WINDOWS) == 0) == tail.isValidSegment(":")) //$NON-NLS-1$ return tail.setDevice(device).makeAbsolute().makeUNC(isUNC()); //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(device, newSegments, (flags & (HAS_LEADING | IS_UNC | IS_FOR_WINDOWS)) | (tail.hasTrailingSeparator() ? HAS_TRAILING : 0)); String tailFirstSegment = newSegments[myLen]; if (tailFirstSegment.equals("..") || tailFirstSegment.equals(".")) { //$NON-NLS-1$ //$NON-NLS-2$ result.canonicalize(); } return result; }
@Override public IPath append(IPath tail) { //optimize some easy cases if (tail == null || tail.segmentCount() == 0) return this; //these call chains look expensive, but in most cases they are no-ops //the tail must be for the same platform as this instance if (this.isEmpty() && ((flags & IS_FOR_WINDOWS) == 0) == tail.isValidSegment(":")) //$NON-NLS-1$ return tail.setDevice(device).makeRelative().makeUNC(isUNC()); if (this.isRoot() && ((flags & IS_FOR_WINDOWS) == 0) == tail.isValidSegment(":")) //$NON-NLS-1$ return tail.setDevice(device).makeAbsolute().makeUNC(isUNC()); //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(device, newSegments, (flags & (HAS_LEADING | IS_UNC | IS_FOR_WINDOWS)) | (tail.hasTrailingSeparator() ? HAS_TRAILING : 0)); String tailFirstSegment = newSegments[myLen]; if (tailFirstSegment.equals("..") || tailFirstSegment.equals(".")) { //$NON-NLS-1$ //$NON-NLS-2$ result.canonicalize(); } return result; }
if (i == 0 && path.isUNC()) { realPath = realPath.append(segment.toUpperCase()); realPath = realPath.makeUNC(true); } else { if (MACOSX) {
if (i == 0 && path.isUNC()) { realPath = realPath.append(segment.toUpperCase()); realPath = realPath.makeUNC(true); } else { if (MACOSX) {
if (i == 0 && path.isUNC()) { realPath = realPath.append(segment.toUpperCase()); realPath = realPath.makeUNC(true); } else { if (MACOSX) {