Java Code Examples for com.intellij.openapi.util.io.FileUtil#getTempDirectory()

The following examples show how to use com.intellij.openapi.util.io.FileUtil#getTempDirectory() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CreateDesktopEntryAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static File prepare() throws IOException {
  File distributionDirectory = ContainerPathManager.get().getAppHomeDirectory();
  String name = ApplicationNamesInfo.getInstance().getFullProductName();

  final String iconPath = AppUIUtil.findIcon(distributionDirectory.getPath());
  if (iconPath == null) {
    throw new RuntimeException(ApplicationBundle.message("desktop.entry.icon.missing", distributionDirectory.getPath()));
  }

  final File execPath = new File(distributionDirectory, "consulo.sh");
  if (!execPath.exists()) {
    throw new RuntimeException(ApplicationBundle.message("desktop.entry.script.missing", distributionDirectory.getPath()));
  }

  final String wmClass = AppUIUtil.getFrameClass();

  final String content = ExecUtil.loadTemplate(CreateDesktopEntryAction.class.getClassLoader(), "entry.desktop", ContainerUtil
          .newHashMap(Arrays.asList("$NAME$", "$SCRIPT$", "$ICON$", "$WM_CLASS$"), Arrays.asList(name, execPath.getPath(), iconPath, wmClass)));

  final String entryName = wmClass + ".desktop";
  final File entryFile = new File(FileUtil.getTempDirectory(), entryName);
  FileUtil.writeToFile(entryFile, content);
  entryFile.deleteOnExit();
  return entryFile;
}
 
Example 2
Source File: FileTemplateConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static boolean isValidFilename(final String filename) {
  if ( filename.contains("/") || filename.contains("\\") || filename.contains(":") ) {
    return false;
  }
  final File tempFile = new File (FileUtil.getTempDirectory() + File.separator + filename);
  return FileUtil.ensureCanCreateFile(tempFile);
}
 
Example 3
Source File: CamelProjectComponentTestIT.java    From camel-idea-plugin with Apache License 2.0 4 votes vote down vote up
@Override
protected void setUp() throws Exception {
    super.setUp();
    root = new File(FileUtil.getTempDirectory());
}
 
Example 4
Source File: StorageTest.java    From consulo with Apache License 2.0 4 votes vote down vote up
private String getFileName() {
  return FileUtil.getTempDirectory() + File.separatorChar + getName();
}