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

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

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

FileUtil.toSystemDependentName介绍

暂无

代码示例

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

protected void loadProject(String projectPath, Map<String, String> pathVariables){
 try{
  String testDataRootPath = getTestDataRootPath();
  String fullProjectPath = FileUtil.toSystemDependentName(testDataRootPath != null ? testDataRootPath + "/" + projectPath : projectPath);
  Map<String, String> allPathVariables = new HashMap<String, String>(pathVariables.size() + 1);
  allPathVariables.putAll(pathVariables);
  allPathVariables.put(PathMacroUtil.APPLICATION_HOME_DIR, PathManager.getHomePath());
  JpsProjectLoader.loadProject(myProject, allPathVariables, fullProjectPath);
 } catch (IOException e) {
  throw new RuntimeException(e);
 }
}

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

protected static void change(String filePath, @Nullable String newContent){
 try{
  File file = new File(FileUtil.toSystemDependentName(filePath));
  assertTrue("File " + file.getAbsolutePath() + " doesn't exist", file.exists());
  if(newContent != null){
   FileUtil.writeToFile(file, newContent);
  }
  long oldTimeStamp = FileSystemUtil.lastModified(file);
  long time = System.currentTimeMillis();
  setLastModified(file, time);
  if(FileSystemUtil.lastModified(file) <= oldTimeStamp){
   setLastModified(file, time + 1);
   long newTimeStamp = FileSystemUtil.lastModified(file);
   if(newTimeStamp <= oldTimeStamp){
    // Mac OS and som versions of Linux truncates timestamp to nearest second
    setLastModified(file, time + 1000);
    newTimeStamp = FileSystemUtil.lastModified(file);
    assertTrue("Failed to change timestamp for " + file.getAbsolutePath(), newTimeStamp > oldTimeStamp);
   }
   sleepUntil(newTimeStamp);
  }
 } catch (IOException e) {
  e.printStackTrace();
 }
}

代码示例来源: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: Camelcade/Perl5-IDEA

@Nullable
@Override
public String doGetLocalPath(@NotNull String remotePathName) {
 String windowsPath = WSLUtil.getWindowsPath(remotePathName);
 return windowsPath != null ? windowsPath : FileUtil.toSystemDependentName(new File(getLocalCacheRoot(), remotePathName).getPath());
}

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

/**
  * Reverse operation for {@link #linuxisePath(String)}
  */
 @NotNull
 public static String unLinuxisePath(@NotNull String linuxisedPath) {
  if (!SystemInfo.isWindows || linuxisedPath.length() < 2) {
   return linuxisedPath;
  }
  String normalizedPath = FileUtil.toSystemIndependentName(linuxisedPath);
  if (normalizedPath.charAt(0) != '/') {
   throw new RuntimeException("Badly formatted path: " + linuxisedPath);
  }
  char driveLetter = normalizedPath.charAt(1);
  if (!Character.isLetter(driveLetter)) {
   throw new RuntimeException("Unexpected drive letter: " + linuxisedPath);
  }
  return FileUtil.toSystemDependentName(driveLetter + ":" + (linuxisedPath.length() > 2 ? linuxisedPath.substring(2) : ""));
 }
}

代码示例来源:origin: GoogleCloudPlatform/google-cloud-intellij

@Override
protected String getTestDataPath() {
 File currentWorkingDirectory = new File("");
 String homePathParent = currentWorkingDirectory.getAbsolutePath();
 return homePathParent + FileUtil.toSystemDependentName("/testData/");
}

代码示例来源:origin: JetBrains/Grammar-Kit

private static boolean collectFiles(List<File> result, List<String> roots, String... urls) {
 main: for (int i = 0; i < urls.length; i++) {
  String url = urls[i];
  String name = url.substring(url.lastIndexOf("/") + 1);
  for (String root : roots) {
   root = StringUtil.trimEnd(root, JarFileSystem.JAR_SEPARATOR);
   String rootName = root.substring(root.lastIndexOf("/") + 1);
   int length = StringUtil.commonPrefix(rootName.toLowerCase(Locale.ENGLISH), name.toLowerCase(Locale.ENGLISH)).length();
   if (length < 4) continue;
   if (rootName.length() == length || rootName.length() > length && "-_.".indexOf(rootName.charAt(length)) > -1) {
    File file = new File(FileUtil.toSystemDependentName(VfsUtil.urlToPath(root)));
    if (file.exists() && file.isFile()) {
     result.add(file);
     continue main;
    }
   }
  }
  if(result.size() < i) break;
 }
 if (result.size() == urls.length) return true;
 result.clear();
 return false;
}

代码示例来源:origin: JetBrains/Grammar-Kit

@Nullable
private static String getCommunitySrcUrlInner(@NotNull Sdk projectSdk) {
 String homePath = projectSdk.getHomePath();
 String API_SCR = "/platform/lang-api/src";
 if (homePath != null) {
  for (String prefix : Arrays.asList("community", "")) {
   File file = new File(homePath, FileUtil.toSystemDependentName(prefix + API_SCR));
   if (file.exists() && file.isDirectory()) {
    return VfsUtil.pathToUrl(FileUtil.toSystemDependentName(homePath + "/" + prefix));
   }
  }
 }
 String[] sources = projectSdk.getRootProvider().getUrls(OrderRootType.SOURCES);
 for (String source : sources) {
  String communityPath = StringUtil.trimEnd(source, API_SCR);
  if (communityPath.length() < source.length()) {
   return communityPath;
  }
 }
 return null;
}

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

@Override
 protected void customizeCellRenderer(@NotNull JList<? extends VirtualFile> list,
                    VirtualFile value,
                    int index,
                    boolean selected,
                    boolean hasFocus) {
  setIcon(PerlIcons.PERL_LANGUAGE_ICON);
  append(FileUtil.toSystemDependentName(value.getPath()));
 }
});

代码示例来源:origin: intellij-dlanguage/intellij-dlanguage

@Override
public void moduleCompileOutputChanged(final String baseUrl, final String moduleName) {
  if (getCompilerExtension().isCompilerOutputPathInherited()) {
    if (baseUrl != null) {
      myOutputPathPanel.setText(FileUtil.toSystemDependentName(VfsUtilCore.urlToPath(baseUrl + "/" + CompilerModuleExtension
          .PRODUCTION + "/" + moduleName)));
      myTestsOutputPathPanel.setText(FileUtil.toSystemDependentName(VfsUtilCore.urlToPath(baseUrl + "/" + CompilerModuleExtension
          .TEST + "/" + moduleName)));
    }
    else {
      myOutputPathPanel.setText(null);
      myTestsOutputPathPanel.setText(null);
    }
  }
}

代码示例来源:origin: intellij-dlanguage/intellij-dlanguage

@NotNull
public VirtualFile getDFile() throws RuntimeConfigurationError {
  final String filePath = getdFilePath();
  if (StringUtil.isEmptyOrSpaces(filePath)) {
    throw new RuntimeConfigurationError(DlangBundle.INSTANCE.message("path.to.dlanguage.file.not.set"));
  }
  final VirtualFile dFile = LocalFileSystem.getInstance().findFileByPath(filePath);
  if (dFile == null || dFile.isDirectory()) {
    throw new RuntimeConfigurationError(DlangBundle.INSTANCE.message("dlanguage.file.not.found", FileUtil.toSystemDependentName(filePath)));
  }
  if (dFile.getFileType() != DlangFileType.INSTANCE) {
    throw new RuntimeConfigurationError(DlangBundle.INSTANCE.message("not.a.dlanguage.file", FileUtil.toSystemDependentName(filePath)));
  }
  return dFile;
}

代码示例来源:origin: JetBrains/Grammar-Kit

indicator.setFraction((double)i / l);
indicator.setText2(file.getPath());
String sourcePath = FileUtil.toSystemDependentName(PathUtil.getCanonicalPath(file.getParent().getPath()));
VirtualFile target = rootMap.get(file);
if (target == null) return;

代码示例来源:origin: intellij-dlanguage/intellij-dlanguage

private void updateOutputPathPresentation() {
  if (getCompilerExtension().isCompilerOutputPathInherited()) {
    final String baseUrl = ProjectStructureConfigurable.getInstance(myProject).getProjectConfig().getCompilerOutputUrl();
    moduleCompileOutputChanged(baseUrl, getModel().getModule().getName());
  } else {
    final VirtualFile compilerOutputPath = getCompilerExtension().getCompilerOutputPath();
    if (compilerOutputPath != null) {
      myOutputPathPanel.setText(FileUtil.toSystemDependentName(compilerOutputPath.getPath()));
    }
    else {
      final String compilerOutputUrl = getCompilerExtension().getCompilerOutputUrl();
      if (compilerOutputUrl != null) {
        myOutputPathPanel.setText(FileUtil.toSystemDependentName(VfsUtilCore.urlToPath(compilerOutputUrl)));
      }
    }
    final VirtualFile testsOutputPath = getCompilerExtension().getCompilerOutputPathForTests();
    if (testsOutputPath != null) {
      myTestsOutputPathPanel.setText(FileUtil.toSystemDependentName(testsOutputPath.getPath()));
    }
    else {
      final String testsOutputUrl = getCompilerExtension().getCompilerOutputUrlForTests();
      if (testsOutputUrl != null) {
        myTestsOutputPathPanel.setText(FileUtil.toSystemDependentName(VfsUtilCore.urlToPath(testsOutputUrl)));
      }
    }
  }
}

代码示例来源:origin: intellij-dlanguage/intellij-dlanguage

public static void initDFileTextWithBrowse(final @NotNull Project project,
                      final @NotNull TextFieldWithBrowseButton textWithBrowse) {
  textWithBrowse.getButton().addActionListener(event -> {
    final String initialPath = FileUtil.toSystemIndependentName(textWithBrowse.getText().trim());
    final VirtualFile initialFile = initialPath.isEmpty() ? null : LocalFileSystem.getInstance().findFileByPath(initialPath);
    final PsiFile initialPsiFile = initialFile == null ? null : PsiManager.getInstance(project).findFile(initialFile);
    final TreeFileChooser fileChooser = TreeFileChooserFactory.getInstance(project).createFileChooser(
      DlangBundle.INSTANCE.message("choose.dlanguage.main.file"),
      initialPsiFile,
      DlangFileType.INSTANCE,
      file -> !DlangWritingAccessProvider.isInDLanguageSdkOrDLanguagePackagesFolder(file)
    );
    fileChooser.showDialog();
    final PsiFile selectedFile = fileChooser.getSelectedFile();
    final VirtualFile virtualFile = selectedFile == null ? null : selectedFile.getVirtualFile();
    if (virtualFile != null) {
      final String path = FileUtil.toSystemDependentName(virtualFile.getPath());
      textWithBrowse.setText(path);
    }
  });
}

代码示例来源:origin: google/ijaas

@Override
protected Response handle(Request request) {
 File file = new File(FileUtil.toSystemDependentName(request.file));
 if (!file.exists()) {
  throw new RuntimeException("Cannot find the file");

相关文章