Java 类com.intellij.util.PathUtilRt 实例源码

项目:intellij-ce-playground    文件:ArtifactCompilerInstructionCreatorBase.java   
@Override
public boolean accept(@NotNull String fullFilePath) {
  if (myBaseFilter != null && !myBaseFilter.accept(fullFilePath)) return false;

  if (myIgnoredFileIndex.isIgnored(PathUtilRt.getFileName(fullFilePath))) {
    return false;
  }

  if (!myIncludeExcluded) {
    final File file = JarPathUtil.getLocalFile(fullFilePath);
    if (myRootsIndex.isExcluded(file)) {
      return false;
    }
  }
  return true;
}
项目:tools-idea    文件:ArtifactCompilerInstructionCreatorBase.java   
@Override
public boolean accept(@NotNull String fullFilePath) {
  if (myBaseFilter != null && !myBaseFilter.accept(fullFilePath)) return false;

  if (myIgnoredFileIndex.isIgnored(PathUtilRt.getFileName(fullFilePath))) {
    return false;
  }

  if (!myIncludeExcluded) {
    final File file = JarPathUtil.getLocalFile(fullFilePath);
    if (myRootsIndex.isExcluded(file)) {
      return false;
    }
  }
  return true;
}
项目:consulo    文件:QuickListsManager.java   
@Override
public void initComponent() {
  for (BundledQuickListsProvider provider : BundledQuickListsProvider.EP_NAME.getExtensions()) {
    for (final String path : provider.getBundledListsRelativePaths()) {
      mySchemesManager.loadBundledScheme(path, provider, new ThrowableConvertor<Element, QuickList, Throwable>() {
        @Override
        public QuickList convert(Element element) throws Throwable {
          QuickList item = createItem(element);
          item.getExternalInfo().setHash(JDOMUtil.getTreeHash(element, true));
          item.getExternalInfo().setPreviouslySavedName(item.getName());
          item.getExternalInfo().setCurrentFileName(PathUtilRt.getFileName(path));
          return item;
        }
      });
    }
  }
  mySchemesManager.loadSchemes();
  registerActions();
}
项目:consulo    文件:DefaultVcsRootPolicy.java   
public String getProjectConfigurationMessage(@Nonnull Project project) {
  boolean isDirectoryBased = ProjectKt.isDirectoryBased(project);
  final StringBuilder sb = new StringBuilder("Content roots of all modules");
  if (isDirectoryBased) {
    sb.append(", ");
  }
  else {
    sb.append(", and ");
  }
  sb.append("all immediate descendants of project base directory");
  if (isDirectoryBased) {
    sb.append(", and ");
    sb.append(PathUtilRt.getFileName(ProjectKt.getDirectoryStoreFile(project).getPresentableUrl())).append(" directory contents");
  }
  return sb.toString();
}
项目:intellij-ce-playground    文件:Utils.java   
public static File getDataStorageRoot(final File systemRoot, String projectPath) {
  projectPath = FileUtil.toCanonicalPath(projectPath);
  if (projectPath == null) {
    return null;
  }

  String name;
  final int locationHash;

  final File rootFile = new File(projectPath);
  if (!rootFile.isDirectory() && projectPath.endsWith(".ipr")) {
    name = StringUtil.trimEnd(rootFile.getName(), ".ipr");
    locationHash = projectPath.hashCode();
  }
  else {
    File directoryBased = null;
    if (PathMacroUtil.DIRECTORY_STORE_NAME.equals(rootFile.getName())) {
      directoryBased = rootFile;
    }
    else {
      File child = new File(rootFile, PathMacroUtil.DIRECTORY_STORE_NAME);
      if (child.exists()) {
        directoryBased = child;
      }
    }
    if (directoryBased == null) {
      return null;
    }
    name = PathUtilRt.suggestFileName(JpsProjectLoader.getDirectoryBaseProjectName(directoryBased));
    locationHash = directoryBased.getPath().hashCode();
  }

  return new File(systemRoot, name.toLowerCase(Locale.US) + "_" + Integer.toHexString(locationHash));
}
项目:intellij-ce-playground    文件:LocalFileStorage.java   
public File createLocalFile(@NotNull Url url) throws IOException {
  String baseName = PathUtilRt.getFileName(url.getPath());
  int index = baseName.lastIndexOf('.');
  String prefix = index == -1 ? baseName : baseName.substring(0, index);
  String suffix = index == -1 ? "" : baseName.substring(index+1);
  prefix = PathUtilRt.suggestFileName(prefix);
  suffix = PathUtilRt.suggestFileName(suffix);
  File file = FileUtil.findSequentNonexistentFile(myStorageIODirectory, prefix, suffix);
  FileUtilRt.createIfNotExists(file);
  return file;
}
项目:consulo    文件:PersistentUtil.java   
@Nonnull
public static File getStorageFile(@Nonnull String storageKind, @Nonnull String logId, int version) {
  File subdir = new File(LOG_CACHE, storageKind);
  String safeLogId = PathUtilRt.suggestFileName(logId, true, true);
  final File mapFile = new File(subdir, safeLogId + "." + version);
  if (!mapFile.exists()) {
    IOUtil.deleteAllFilesStartingWith(new File(subdir, safeLogId));
  }
  return mapFile;
}
项目:consulo    文件:PersistentUtil.java   
public static void cleanupOldStorageFile(@Nonnull String storageKind, @Nonnull String logId) {
  File subdir = new File(LOG_CACHE, storageKind);
  String safeLogId = PathUtilRt.suggestFileName(logId, true, true);
  IOUtil.deleteAllFilesStartingWith(new File(subdir, safeLogId));

  File[] files = subdir.listFiles();
  if (files != null && files.length == 0) {
    subdir.delete();
  }
}
项目:consulo    文件:PersistentUtil.java   
@Nonnull
public static File getStorageFile(@Nonnull String subdirName,
                                  @Nonnull String kind,
                                  @Nonnull String id,
                                  int version,
                                  boolean cleanupOldVersions) {
  File subdir = new File(LOG_CACHE, subdirName);
  String safeLogId = PathUtilRt.suggestFileName(id, true, true);
  File file = new File(subdir, safeLogId + "." + kind + "." + version);
  if (cleanupOldVersions && !file.exists()) {
    IOUtil.deleteAllFilesStartingWith(new File(subdir, safeLogId + "." + kind));
  }
  return file;
}
项目:consulo    文件:StateStorageManagerImpl.java   
@Nonnull
private StateStorage createFileStateStorage(@Nonnull String fileSpec, @Nullable RoamingType roamingType) {
  String filePath = FileUtil.toSystemIndependentName(expandMacros(fileSpec));

  if (!ourHeadlessEnvironment && PathUtilRt.getFileName(filePath).lastIndexOf('.') < 0) {
    throw new IllegalArgumentException("Extension is missing for storage file: " + filePath);
  }

  if (roamingType == RoamingType.PER_USER && fileSpec.equals(StoragePathMacros.WORKSPACE_FILE)) {
    roamingType = RoamingType.DISABLED;
  }

  beforeFileBasedStorageCreate();
  return new FileBasedStorage(filePath, fileSpec, roamingType, getMacroSubstitutor(fileSpec), myRootTagName, StateStorageManagerImpl.this,
                              createStorageTopicListener(), myStreamProvider) {
    @Override
    @Nonnull
    protected StorageData createStorageData() {
      return StateStorageManagerImpl.this.createStorageData(myFileSpec, getFilePath());
    }

    @Override
    protected boolean isUseXmlProlog() {
      return StateStorageManagerImpl.this.isUseXmlProlog();
    }
  };
}
项目:intellij-ce-playground    文件:BuildDataPathsImpl.java   
@Override
public File getTargetDataRoot(BuildTarget<?> target) {
  return new File(getTargetTypeDataRoot(target.getTargetType()), PathUtilRt.suggestFileName(target.getId(), true, false));
}
项目:intellij-ce-playground    文件:ModuleUtilCore.java   
@NotNull
public static String getModuleDirPath(@NotNull Module module) {
  return PathUtilRt.getParentPath(module.getModuleFilePath());
}
项目:intellij-ce-playground    文件:Attachment.java   
@NotNull
public String getName() {
  return PathUtilRt.getFileName(myPath);
}
项目:intellij-ce-playground    文件:AndroidResourcePackagingBuilder.java   
private static boolean doPackageResources(@NotNull final CompileContext context,
                                          @NotNull File manifestFile,
                                          @NotNull IAndroidTarget target,
                                          @NotNull String[] resourceDirPaths,
                                          @NotNull String[] assetsDirPaths,
                                          @NotNull String outputPath,
                                          boolean releasePackage,
                                          @NotNull String moduleName,
                                          @NotNull BuildOutputConsumer outputConsumer,
                                          @Nullable String customManifestPackage,
                                          @Nullable String additionalParameters) {
  try {
    final IgnoredFileIndex ignoredFileIndex = context.getProjectDescriptor().getIgnoredFileIndex();

    final Map<AndroidCompilerMessageKind, List<String>> messages = AndroidApt
      .packageResources(target, -1, manifestFile.getPath(), resourceDirPaths, assetsDirPaths, outputPath, null,
                        !releasePackage, 0, customManifestPackage, additionalParameters, new FileFilter() {
        @Override
        public boolean accept(File pathname) {
          return !ignoredFileIndex.isIgnored(PathUtilRt.getFileName(pathname.getPath()));
        }
      });

    AndroidJpsUtil.addMessages(context, messages, BUILDER_NAME, moduleName);
    final boolean success = messages.get(AndroidCompilerMessageKind.ERROR).size() == 0;

    if (success) {
      final List<String> srcFiles = new ArrayList<String>();
      srcFiles.add(manifestFile.getPath());
      fillRecursively(resourceDirPaths, srcFiles);
      fillRecursively(assetsDirPaths, srcFiles);

      outputConsumer.registerOutputFile(new File(outputPath), srcFiles);
    }
    return success;
  }
  catch (final IOException e) {
    AndroidJpsUtil.reportExceptionError(context, null, e, BUILDER_NAME);
    return false;
  }
}
项目:intellij-ce-playground    文件:AbstractJavaFxPackager.java   
protected String getArtifactRootName() {
  return PathUtilRt.getFileName(getArtifactOutputFilePath());
}
项目:tools-idea    文件:BuildDataPathsImpl.java   
@Override
public File getTargetDataRoot(BuildTarget<?> target) {
  return new File(getTargetTypeDataRoot(target.getTargetType()), PathUtilRt.suggestFileName(target.getId(), true, false));
}
项目:tools-idea    文件:ClasspathBootstrap.java   
public static List<String> getBuildProcessApplicationClasspath() {
  final Set<String> cp = ContainerUtil.newHashSet();

  cp.add(getResourcePath(BuildMain.class));

  cp.addAll(PathManager.getUtilClassPath()); // util
  cp.add(getResourcePath(Message.class)); // protobuf
  cp.add(getResourcePath(Version.class)); // netty
  cp.add(getResourcePath(ClassWriter.class));  // asm
  cp.add(getResourcePath(ClassVisitor.class));  // asm-commons
  cp.add(getResourcePath(JpsModel.class));  // jps-model-api
  cp.add(getResourcePath(JpsModelImpl.class));  // jps-model-impl
  cp.add(getResourcePath(JpsProjectLoader.class));  // jps-model-serialization
  cp.add(getResourcePath(AlienFormFileException.class));  // forms-compiler
  cp.add(getResourcePath(GridConstraints.class));  // forms-rt
  cp.add(getResourcePath(CellConstraints.class));  // jGoodies-forms
  cp.add(getResourcePath(NotNullVerifyingInstrumenter.class));  // not-null
  cp.add(getResourcePath(IXMLBuilder.class));  // nano-xml

  final Class<StandardJavaFileManager> optimizedFileManagerClass = getOptimizedFileManagerClass();
  if (optimizedFileManagerClass != null) {
    cp.add(getResourcePath(optimizedFileManagerClass));  // optimizedFileManager
  }

  try {
    final Class<?> cmdLineWrapper = Class.forName("com.intellij.rt.execution.CommandLineWrapper");
    cp.add(getResourcePath(cmdLineWrapper));  // idea_rt.jar
  }
  catch (Throwable ignored) {
  }

  for (JavaCompiler javaCompiler : ServiceLoader.load(JavaCompiler.class)) { // Eclipse compiler
    final String compilerResource = getResourcePath(javaCompiler.getClass());
    final String name = PathUtilRt.getFileName(compilerResource);
    if (name.startsWith("ecj-") && name.endsWith(".jar")) {
      cp.add(compilerResource);
    }
  }

  return ContainerUtil.newArrayList(cp);
}
项目:tools-idea    文件:Attachment.java   
public String getName() {
  return PathUtilRt.getFileName(myPath);
}
项目:tools-idea    文件:AbstractJavaFxPackager.java   
protected String getArtifactRootName() {
  return PathUtilRt.getFileName(getArtifactOutputFilePath());
}
项目:consulo-javafx    文件:AbstractJavaFxPackager.java   
protected String getArtifactRootName() {
  return PathUtilRt.getFileName(getArtifactOutputFilePath());
}
项目:consulo    文件:PersistentUtil.java   
public static boolean cleanupStorageFiles(@Nonnull String subdirName, @Nonnull String id) {
  File subdir = new File(LOG_CACHE, subdirName);
  String safeLogId = PathUtilRt.suggestFileName(id, true, true);
  return deleteWithRenamingAllFilesStartingWith(new File(subdir, safeLogId + "."));
}
项目:consulo    文件:LocalFileSystemBase.java   
@Override
public boolean isValidName(@Nonnull String name) {
  return PathUtilRt.isValidFileName(name, false);
}
项目:consulo    文件:ProjectUtil.java   
private static String getProjectCacheFileName(Project project, boolean forceNameUse, String hashSeparator) {
  String presentableUrl = project.getPresentableUrl();
  String name = forceNameUse || presentableUrl == null ? project.getName() : PathUtilRt.getFileName(presentableUrl).toLowerCase(Locale.US);

  name = PathKt.sanitizeFileName(name, false);

  String locationHash = Integer.toHexString(ObjectUtil.notNull(presentableUrl, name).hashCode());

  name = StringUtil.trimMiddle(name, Math.min(name.length(), 255 - hashSeparator.length() - locationHash.length()), false);

  return name + hashSeparator + locationHash;
}