当前位置: 首页>>代码示例>>Java>>正文


Java FileUtilRt.getParentFile方法代码示例

本文整理汇总了Java中com.intellij.openapi.util.io.FileUtilRt.getParentFile方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtilRt.getParentFile方法的具体用法?Java FileUtilRt.getParentFile怎么用?Java FileUtilRt.getParentFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.util.io.FileUtilRt的用法示例。


在下文中一共展示了FileUtilRt.getParentFile方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: copyClass

import com.intellij.openapi.util.io.FileUtilRt; //导入方法依赖的package包/类
public static File copyClass(final String targetPath, @NonNls final String className, final boolean deleteOnExit) throws IOException{
  final File targetDir = new File(targetPath).getAbsoluteFile();
  final File file = new File(targetDir, className + ".class");
  FileUtil.createParentDirs(file);
  if (deleteOnExit) {
    for (File f = file; f != null && !FileUtil.filesEqual(f, targetDir); f = FileUtilRt.getParentFile(f)) {
      f.deleteOnExit();
    }
  }
  @NonNls final String resourceName = "/" + className + ".class";
  final InputStream stream = CopyResourcesUtil.class.getResourceAsStream(resourceName);
  if (stream == null) {
    throw new IOException("cannot load " + resourceName);
  }
  return copyStreamToFile(stream, file);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:CopyResourcesUtil.java

示例2: getTargetsByOutputFile

import com.intellij.openapi.util.io.FileUtilRt; //导入方法依赖的package包/类
@Override
public Collection<BuildTarget<?>> getTargetsByOutputFile(@NotNull File file) {
  File current = file;
  Collection<BuildTarget<?>> result = null;
  while (current != null) {
    List<BuildTarget<?>> targets = myOutputToTargets.get(current);
    if (targets != null) {
      if (result == null) {
        result = targets;
      }
      else {
        result = new ArrayList<BuildTarget<?>>(result);
        result.addAll(targets);
      }
    }
    current = FileUtilRt.getParentFile(current);
  }
  return result != null ? result : Collections.<BuildTarget<?>>emptyList();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:TargetOutputIndexImpl.java

示例3: findParentDescriptor

import com.intellij.openapi.util.io.FileUtilRt; //导入方法依赖的package包/类
@Override
@Nullable
public <R extends BuildRootDescriptor> R findParentDescriptor(@NotNull File file, @NotNull Collection<? extends BuildTargetType<? extends BuildTarget<R>>> types,
                                                              @Nullable CompileContext context) {
  File current = file;
  int depth = 0;
  while (current != null) {
    final List<R> descriptors = filterDescriptorsByFile(getRootDescriptors(current, types, context), file, depth);
    if (!descriptors.isEmpty()) {
      return descriptors.get(0);
    }
    current = FileUtilRt.getParentFile(current);
    depth++;
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:BuildRootIndexImpl.java

示例4: findAllParentDescriptors

import com.intellij.openapi.util.io.FileUtilRt; //导入方法依赖的package包/类
@Override
@NotNull
public <R extends BuildRootDescriptor> Collection<R> findAllParentDescriptors(@NotNull File file,
                                                                              @Nullable Collection<? extends BuildTargetType<? extends BuildTarget<R>>> types,
                                                                              @Nullable CompileContext context) {
  File current = file;
  List<R> result = null;
  int depth = 0;
  while (current != null) {
    List<R> descriptors = filterDescriptorsByFile(getRootDescriptors(current, types, context), file, depth);
    if (!descriptors.isEmpty()) {
      if (result == null) {
        result = descriptors;
      }
      else {
        result = new ArrayList<R>(result);
        result.addAll(descriptors);
      }
    }
    current = FileUtilRt.getParentFile(current);
    depth++;
  }
  return result != null ? result : Collections.<R>emptyList();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:BuildRootIndexImpl.java

示例5: isExcluded

import com.intellij.openapi.util.io.FileUtilRt; //导入方法依赖的package包/类
@Override
public  boolean isExcluded(File file) {
  if (myFiles.contains(file)) {
    return true;
  }

  if (!myDirectories.isEmpty() || !myRecursivelyExcludedDirectories.isEmpty()) { // optimization
    File parent = FileUtilRt.getParentFile(file);
    if (myDirectories.contains(parent)) {
      return true;
    }

    while (parent != null) {
      if (myRecursivelyExcludedDirectories.contains(parent)) {
        return true;
      }
      parent = FileUtilRt.getParentFile(parent);
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:JpsCompilerExcludesImpl.java

示例6: copyProperties

import com.intellij.openapi.util.io.FileUtilRt; //导入方法依赖的package包/类
public static void copyProperties(final String targetPath, final String fileName) throws IOException {
  final File targetDir = new File(targetPath).getAbsoluteFile();
  final File file = new File(targetDir, fileName);
  FileUtil.createParentDirs(file);
  for (File f = file; f != null && !FileUtil.filesEqual(f, targetDir); f = FileUtilRt.getParentFile(f)) {
    f.deleteOnExit();
  }
  final String resourceName = "/" + fileName;
  final InputStream stream = CopyResourcesUtil.class.getResourceAsStream(resourceName);
  if (stream == null) {
    return;
  }
  copyStreamToFile(stream, file);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:CopyResourcesUtil.java

示例7: computeModuleCharsetMap

import com.intellij.openapi.util.io.FileUtilRt; //导入方法依赖的package包/类
private Map<JpsModule, Set<String>> computeModuleCharsetMap() {
  final Map<JpsModule, Set<String>> map = new THashMap<JpsModule, Set<String>>();
  final Iterable<JavaBuilderExtension> builderExtensions = JpsServiceManager.getInstance().getExtensions(JavaBuilderExtension.class);
  for (Map.Entry<String, String> entry : myUrlToCharset.entrySet()) {
    final String fileUrl = entry.getKey();
    final String charset = entry.getValue();
    File file = JpsPathUtil.urlToFile(fileUrl);
    if (charset == null || (!file.isDirectory() && !shouldHonorEncodingForCompilation(builderExtensions, file))) continue;

    final JavaSourceRootDescriptor rootDescriptor = myRootsIndex.findJavaRootDescriptor(null, file);
    if (rootDescriptor == null) continue;

    final JpsModule module = rootDescriptor.target.getModule();
    Set<String> set = map.get(module);
    if (set == null) {
      set = new LinkedHashSet<String>();
      map.put(module, set);

      final File sourceRoot = rootDescriptor.root;
      File current = FileUtilRt.getParentFile(file);
      String parentCharset = null;
      while (current != null) {
        final String currentCharset = myUrlToCharset.get(FileUtil.toSystemIndependentName(current.getAbsolutePath()));
        if (currentCharset != null) {
          parentCharset = currentCharset;
        }
        if (FileUtil.filesEqual(current, sourceRoot)) {
          break;
        }
        current = FileUtilRt.getParentFile(current);
      }
      if (parentCharset != null) {
        set.add(parentCharset);
      }
    }
    set.add(charset);
  }

  return map;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:41,代码来源:CompilerEncodingConfiguration.java

示例8: findOutputDir

import com.intellij.openapi.util.io.FileUtilRt; //导入方法依赖的package包/类
private File findOutputDir(File src) {
  File file = FileUtilRt.getParentFile(src);
  while (file != null) {
    for (Map.Entry<File, Set<File>> entry : myOutputsMap.entrySet()) {
      if (entry.getValue().contains(file)) {
        return entry.getKey();
      }
    }
    file = FileUtilRt.getParentFile(file);
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:JavacFileManager.java

示例9: isUnder

import com.intellij.openapi.util.io.FileUtilRt; //导入方法依赖的package包/类
public static boolean isUnder(Set<File> ancestors, File file) {
  if (ancestors.isEmpty()) {
    return false; // optimization
  }
  File current = file;
  while (current != null) {
    if (ancestors.contains(current)) {
      return true;
    }
    current = FileUtilRt.getParentFile(current);
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:JpsPathUtil.java


注:本文中的com.intellij.openapi.util.io.FileUtilRt.getParentFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。