コード例 #1
0
ファイル: GitUtils.java プロジェクト: Corly/orion.server
 /**
  * Returns the existing WebProject corresponding to the provided path, or <code>null</code> if no
  * such project exists.
  *
  * @param path path in the form /file/{workspaceId}/{projectName}/[filePath]
  * @return the web project, or <code>null</code>
  */
 public static ProjectInfo projectFromPath(IPath path) {
   if (path == null || path.segmentCount() < 3) return null;
   String workspaceId = path.segment(1);
   String projectName = path.segment(2);
   try {
     return OrionConfiguration.getMetaStore().readProject(workspaceId, projectName);
   } catch (CoreException e) {
     return null;
   }
 }
コード例 #2
0
ファイル: GitUtils.java プロジェクト: Corly/orion.server
 public static String getRelativePath(IPath filePath, IPath pathToGitRoot) {
   StringBuilder sb = new StringBuilder();
   String file = null;
   if (!filePath.hasTrailingSeparator()) {
     file = filePath.lastSegment();
     filePath = filePath.removeLastSegments(1);
   }
   for (int i = 0; i < pathToGitRoot.segments().length; i++) {
     if (pathToGitRoot.segments()[i].equals(".."))
       sb.append(
               filePath.segment(filePath.segments().length - pathToGitRoot.segments().length + i))
           .append("/");
     // else TODO
   }
   if (file != null) sb.append(file);
   return sb.toString();
 }