com.intellij.openapi.util.io.FileUtil.getRelativePath()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(214)

本文整理了Java中com.intellij.openapi.util.io.FileUtil.getRelativePath()方法的一些代码示例,展示了FileUtil.getRelativePath()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtil.getRelativePath()方法的具体详情如下:
包路径:com.intellij.openapi.util.io.FileUtil
类名称:FileUtil
方法名:getRelativePath

FileUtil.getRelativePath介绍

暂无

代码示例

代码示例来源:origin: KronicDeth/intellij-elixir

private static void assertRelativePaths(File[] baseDirs, Collection<File> files, String[] expected){
  List<String> relativePaths = new ArrayList<String>();
  for (File file: files){
   String path = file.getAbsolutePath();
   for(File baseDir:baseDirs){
    if(baseDir != null && FileUtil.isAncestor(baseDir, file, false)){
     path = FileUtil.getRelativePath(baseDir, file);
     break;
    }
   }
   relativePaths.add(FileUtil.toSystemIndependentName(path));
  }
  UsefulTestCase.assertSameElements(relativePaths, expected);

 }
}

代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin

switch (myConfiguration.getKind()) {
 case DIRECTORY:
  String relativePath = FileUtil.getRelativePath(myConfiguration.getWorkingDirectory(),
                          myConfiguration.getDirectoryPath(),
                          File.separatorChar);

代码示例来源:origin: Camelcade/Perl5-IDEA

@Override
public String mapPathToRemote(@NotNull String localPathName) {
 File localPath = new File(localPathName);
 if (FileUtil.isAncestor(myLocalProjectPath, localPath, false)) {
  return FileUtil.toSystemIndependentName(
   new File(myRemoteProjectPath, Objects.requireNonNull(FileUtil.getRelativePath(myLocalProjectPath, localPath))).getPath()
  );
 }
 else {
  return localPathName;
 }
}

代码示例来源:origin: Camelcade/Perl5-IDEA

@NotNull
 @Override
 public String mapPathToLocal(@NotNull String remotePathName) {
  File remotePath = new File(remotePathName);
  if (FileUtil.isAncestor(myRemoteProjectPath, remotePath, false)) {
   return FileUtil.toSystemDependentName(
    new File(myLocalProjectPath, Objects.requireNonNull(FileUtil.getRelativePath(myRemoteProjectPath, remotePath))).getPath()
   );
  }
  else {
   return remotePathName;
  }
 }
}

代码示例来源:origin: uwolfer/gerrit-intellij-plugin

public String getRelativePath(Project project, String absoluteFilePath, String gerritProjectName) {
  Optional<GitRepository> gitRepositoryOptional = gerritGitUtil.getRepositoryForGerritProject(project, gerritProjectName);
  if (!gitRepositoryOptional.isPresent()) return null;
  GitRepository repository = gitRepositoryOptional.get();
  VirtualFile root = repository.getRoot();
  return FileUtil.getRelativePath(new File(root.getPath()), new File(absoluteFilePath));
}

代码示例来源:origin: mustfun/mybatis-plus

@Override
  public String apply(String input) {
    String relativePath = FileUtil.getRelativePath(projectBasePath, input, File.separatorChar);
    Module module = ModuleUtil.findModuleForPsiElement(pathMap.get(input));
    return null == module ? relativePath : ("[" + module.getName() + "] " + relativePath);
  }
}));

代码示例来源:origin: Camelcade/Perl5-IDEA

@Contract("null->null")
@Nullable
public final String getLocalPath(@Nullable String remotePathname) {
 if (remotePathname == null) {
  return null;
 }
 File remotePath = new File(remotePathname);
 File remoteHelpersPath = new File(getHelpersRootPath());
 if (FileUtil.isAncestor(remoteHelpersPath, remotePath, false)) {
  return new File(
   PerlPluginUtil.getPluginHelpersRoot(), Objects.requireNonNull(FileUtil.getRelativePath(remoteHelpersPath, remotePath))).getPath();
 }
 String localPath = doGetLocalPath(remotePathname);
 if (localPath == null) {
  LOG.warn("Unable to map remote to local " + remotePathname + " for " + this);
 }
 return localPath;
}

代码示例来源:origin: Camelcade/Perl5-IDEA

@Nullable
@Override
protected String doGetLocalPath(@NotNull String remotePath) {
 File remoteFile = new File(remotePath);
 if (FileUtil.isAncestor(CONTAINER_ROOT_FILE, remoteFile, false)) {
  return PerlFileUtil.unLinuxisePath('/' + FileUtil.getRelativePath(CONTAINER_ROOT_FILE, remoteFile));
 }
 return FileUtil.toSystemIndependentName(FileUtil.join(getLocalCacheRoot(), remotePath));
}

代码示例来源:origin: Camelcade/Perl5-IDEA

@Contract("null->null")
@Nullable
public final String getRemotePath(@Nullable String localPathName) {
 if (localPathName == null) {
  return null;
 }
 // checking helpers
 File localPathFile = new File(localPathName);
 File localHelpersPath = new File(PerlPluginUtil.getPluginHelpersRoot());
 if (FileUtil.isAncestor(localHelpersPath, localPathFile, false)) {
  return FileUtil.toSystemIndependentName(
   new File(getHelpersRootPath(), Objects.requireNonNull(FileUtil.getRelativePath(localHelpersPath, localPathFile))).getPath());
 }
 // checking local cache if any
 String localCacheRoot = getLocalCacheRoot();
 if (localCacheRoot != null) {
  File localCacheFile = new File(localCacheRoot);
  if (FileUtil.isAncestor(localCacheFile, localPathFile, false)) {
   return FileUtil.toSystemIndependentName("/" + FileUtil.getRelativePath(localCacheFile, localPathFile));
  }
 }
 // mapping with host data
 String remotePath = doGetRemotePath(localPathName);
 if (remotePath == null) {
  LOG.warn("Unable to map local to remote " + localPathName + " for " + this);
 }
 return remotePath;
}

相关文章