project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/ViewBase.java
changeset 610 bfb3ab3f70f2
parent 0 fb279309251b
child 684 8e7900690341
--- a/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/ViewBase.java	Wed Dec 02 14:40:51 2009 -0600
+++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/ViewBase.java	Wed Dec 02 15:02:05 2009 -0600
@@ -447,13 +447,13 @@
 	}
 	
 	public IPath convertModelToProjectPath(IPath modelPath) {
-		if (modelPath == null || modelPath.isAbsolute())
+		if (modelPath == null || isAbsolutePath(modelPath))
 			return modelPath;
 		return fromProjectToRelativePath(getProjectPath(), model.getPath().removeLastSegments(1).append(modelPath), true);
 	}
 	
 	public IPath convertProjectToModelPath(IPath prjPath) {
-		if (prjPath == null || prjPath.isAbsolute())
+		if (prjPath == null || isAbsolutePath(prjPath))
 			return prjPath;
 		return fromProjectToRelativePath(model.getPath().removeLastSegments(1), getProjectPath().append(prjPath));
 	}
@@ -560,4 +560,25 @@
 		else
 			return '\\';
 	}
+
+	/**
+	 * Tell if the path is a Win32 path with drive letter or UNC.
+	 * @param path
+	 */
+	public static boolean isWin32DrivePath(IPath path) {
+		return path.getDevice() != null 
+			|| (!HostOS.IS_WIN32 && path.segmentCount() > 0 && path.segment(0).matches("[A-Za-z]:"));
+	}
+
+	/**
+	 * Tell if the path is absolute -- e.g., according to the host or to Windows conventions.
+	 * @param path
+	 */
+	public static boolean isAbsolutePath(IPath path) {
+		if (path.isAbsolute())
+			return true;
+		if (isWin32DrivePath(path))
+			return true;
+		return false;
+	}
 }