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


Java FileUtil.createTempDirectory方法代码示例

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


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

示例1: testBadFileName

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public void testBadFileName() throws Exception {
  if (!SystemInfo.isUnix) {
    System.err.println(getName() + " skipped: " + SystemInfo.OS_NAME);
    return;
  }

  final File dir = FileUtil.createTempDirectory("test.", ".dir");
  final File file = FileUtil.createTempFile(dir, "test\\", "\\txt", true);

  final VirtualFile vDir = myFS.refreshAndFindFileByIoFile(dir);
  assertNotNull(vDir);
  assertEquals(0, vDir.getChildren().length);

  ((VirtualFileSystemEntry)vDir).markDirtyRecursively();
  vDir.refresh(false, true);

  final VirtualFile vFile = myFS.refreshAndFindFileByIoFile(file);
  assertNull(vFile);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:LocalFileSystemTest.java

示例2: setUp

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
  super.setUp();

  baseDir = new File(PathManagerEx.getTestDataPath(getClass()) + File.separator + "compileServer" + File.separator + "incremental" + File.separator + groupName + File.separator + getProjectName());
  workDir = FileUtil.createTempDirectory("jps-build", null);

  FileUtil.copyDir(baseDir, workDir, new FileFilter() {
    @Override
    public boolean accept(File file) {
      String name = file.getName();
      return !name.endsWith(".new") && !name.endsWith(".delete");
    }
  });

  String outputPath = getAbsolutePath("out");
  JpsJavaExtensionService.getInstance().getOrCreateProjectExtension(myProject).setOutputUrl(JpsPathUtil.pathToUrl(outputPath));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:IncrementalTestCase.java

示例3: setModuleOutput

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
private String setModuleOutput(JpsModule module, boolean tests) {
  try {
    File file = FileUtil.createTempDirectory(module.getName(), tests ? "testSrc" : "src");
    JpsJavaModuleExtension extension = getJavaService().getOrCreateModuleExtension(module);
    String url = JpsPathUtil.getLibraryRootUrl(file);
    if (tests) {
      extension.setTestOutputUrl(url);
    }
    else {
      extension.setOutputUrl(url);
    }
    return url;
  }
  catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:JpsDependenciesEnumeratorTest.java

示例4: setUp

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
  if (ourOutputRoot == null) {
    ourOutputRoot = FileUtil.createTempDirectory("ExecutionTestCase", null, true);
  }
  myModuleOutputDir = new File(ourOutputRoot, PathUtil.getFileName(getTestAppPath()));
  myChecker = initOutputChecker();
  EdtTestUtil.runInEdtAndWait(new ThrowableRunnable<Throwable>() {
    @Override
    public void run() throws Throwable {
      ExecutionTestCase.super.setUp();
    }
  });
  if (!myModuleOutputDir.exists()) {
    myCompilerTester = new CompilerTester(myProject, Arrays.asList(ModuleManager.getInstance(myProject).getModules()));
    List<CompilerMessage> messages = myCompilerTester.rebuild();
    for (CompilerMessage message : messages) {
      if (message.getCategory() == CompilerMessageCategory.ERROR) {
        FileUtil.delete(myModuleOutputDir);
        fail("Compilation failed: " + message);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:ExecutionTestCase.java

示例5: assertFileEqual

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
private void assertFileEqual(File file, String relativePath) {
  try {
    Assert.assertEquals("in " + relativePath, myName, file.getName());
    if (myArchive) {
      final File dirForExtracted = FileUtil.createTempDirectory("extracted_archive", null, false);
      ZipUtil.extract(file, dirForExtracted, null);
      assertDirectoryEqual(dirForExtracted, relativePath);
      FileUtil.delete(dirForExtracted);
    }
    else if (myDirectory) {
      Assert.assertTrue(relativePath + file.getName() + " is not a directory", file.isDirectory());
      assertDirectoryEqual(file, relativePath);
    }
    else if (myContent != null) {
      final String content = FileUtil.loadFile(file);
      Assert.assertEquals("content mismatch for " + relativePath, myContent, content);
    }
  }
  catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:TestFileSystemItem.java

示例6: testCheckoutImpl

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
private File testCheckoutImpl(final String url) throws IOException {
  final File root = FileUtil.createTempDirectory("checkoutRoot", "");
  root.deleteOnExit();
  Assert.assertTrue(root.exists());
  SvnCheckoutProvider
    .checkout(myProject, root, url, SVNRevision.HEAD, Depth.INFINITY, false, new CheckoutProvider.Listener() {
      @Override
      public void directoryCheckedOut(File directory, VcsKey vcs) {
      }

      @Override
      public void checkoutCompleted() {
      }
    }, WorkingCopyFormat.ONE_DOT_SEVEN);
  final int[] cnt = new int[1];
  cnt[0] = 0;
  FileUtil.processFilesRecursively(root, new Processor<File>() {
    @Override
    public boolean process(File file) {
      ++ cnt[0];
      return ! (cnt[0] > 1);
    }
  });
  Assert.assertTrue(cnt[0] > 1);
  return root;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:SvnProtocolsTest.java

示例7: copySwaggerUiToTempDir

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@NotNull
private File copySwaggerUiToTempDir() throws IOException, URISyntaxException {
    final ClassLoader classLoader = getClass().getClassLoader();
    final File file = new File(classLoader.getResource(SWAGGER_UI_FOLDER_NAME).toURI());
    final File tempSwaggerUiDir = FileUtil.createTempDirectory(SWAGGER_UI_FOLDER_NAME, "", true);

    FileUtil.copyDirContent(file, tempSwaggerUiDir);

    return tempSwaggerUiDir;
}
 
开发者ID:zalando,项目名称:intellij-swagger,代码行数:11,代码来源:SwaggerUiCreator.java

示例8: generateFromArchetype

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
private void generateFromArchetype(final Project project, final VirtualFile pom) {
  final File workingDir;
  try {
    workingDir = FileUtil.createTempDirectory("archetype", "tmp");
    workingDir.deleteOnExit();
  }
  catch (IOException e) {
    showError(project, e);
    return;
  }

  MavenRunnerParameters params = new MavenRunnerParameters(
    false, workingDir.getPath(),
    Collections.singletonList("org.apache.maven.plugins:maven-archetype-plugin:RELEASE:generate"),
    Collections.<String>emptyList());

  MavenRunner runner = MavenRunner.getInstance(project);
  MavenRunnerSettings settings = runner.getState().clone();
  Map<String, String> props = settings.getMavenProperties();

  props.put("interactiveMode", "false");
  //props.put("archetypeGroupId", myArchetype.groupId);
  //props.put("archetypeArtifactId", myArchetype.artifactId);
  //props.put("archetypeVersion", myArchetype.version);
  //if (myArchetype.repository != null) props.put("archetypeRepository", myArchetype.repository);

  //props.put("groupId", myProjectId.getGroupId());
  //props.put("artifactId", myProjectId.getArtifactId());
  //props.put("version", myProjectId.getVersion());

  props.putAll(myPropertiesToCreateByArtifact);

  runner.run(params, settings, new Runnable() {
    public void run() {
      copyGeneratedFiles(workingDir, pom, project);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:MavenModuleBuilderHelper.java

示例9: getUnzipToDir

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
private static File getUnzipToDir(@Nullable ProgressIndicator progress,
                                  @NotNull File targetDir,
                                  boolean unwrapSingleTopLevelFolder) throws IOException {
  if (progress != null) {
    progress.setText("Extracting...");
  }
  if (unwrapSingleTopLevelFolder) {
    return FileUtil.createTempDirectory("unzip-dir-", null);
  }
  return targetDir;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:ZipUtil.java

示例10: addSourceRoot

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
private static String addSourceRoot(JpsModule module, boolean tests) {
  try {
    File file = FileUtil.createTempDirectory(module.getName(), tests ? "testSrc" : "src");
    return module.addSourceRoot(JpsPathUtil.getLibraryRootUrl(file), tests ? JavaSourceRootType.TEST_SOURCE : JavaSourceRootType.SOURCE).getUrl();
  }
  catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:JpsDependenciesEnumeratorTest.java

示例11: testCompileJava

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public void testCompileJava() throws IOException {
  File srcDir = PathManagerEx.findFileUnderProjectHome("plugins/maven/jps-plugin/testData/compiler/classpathTest", getClass());
  File workDir = FileUtil.createTempDirectory("mavenJavaBuild", null);
  FileUtil.copyDir(srcDir, workDir);
  addJdk("1.6");
  loadProject(workDir.getAbsolutePath());
  BuildResult result = doBuild(CompileScopeTestBuilder.rebuild().all());
  result.assertFailed();
  BuildMessage message = assertOneElement(result.getMessages(BuildMessage.Kind.ERROR));
  assertTrue(message.toString(), message.getMessageText().contains("Maven project configuration") && message.getMessageText().contains("isn't available."));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:JpsMavenJavaBuildingTest.java

示例12: unicodeClassPath

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Test
public void unicodeClassPath() throws Exception {
  assumeTrue(UNICODE != null);

  File dir = FileUtil.createTempDirectory("spaces 'and quotes' and " + UNICODE, ".tmp");
  try {
    Pair<GeneralCommandLine, File> command = makeHelperCommand(dir, CommandTestHelper.ARG, "test");
    String output = execHelper(command);
    assertEquals("test\n", StringUtil.convertLineSeparators(output));
  }
  finally {
    FileUtil.delete(dir);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:GeneralCommandLineTest.java

示例13: testExpectedFailureOnBrokenZipArchive

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Test
public void testExpectedFailureOnBrokenZipArchive() throws Exception {
  File tempDir = FileUtil.createTempDirectory("unzip-test-", null);
  File file = new File(getZipParentDir(), "invalid-archive.zip");
  try {
    ZipUtil.unzip(null, tempDir, file, null, null, true);
    Assert.fail("Zip archive is broken, but it was unzipped without exceptions.");
  }
  catch (IOException e) {
    // expected exception
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:ZipUtilTest.java

示例14: buildArtifact

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@NotNull
public static Map<AndroidCompilerMessageKind, List<String>> buildArtifact(@NotNull String artifactName,
                                                                          @NotNull String messagePrefix,
                                                                          @NotNull String sdkLocation,
                                                                          @NotNull IAndroidTarget target,
                                                                          @Nullable String artifactFilePath,
                                                                          @NotNull String keyStorePath,
                                                                          @Nullable String keyAlias,
                                                                          @Nullable String keyStorePassword,
                                                                          @Nullable String keyPassword)
  throws GeneralSecurityException, IOException {
  final Map<AndroidCompilerMessageKind, List<String>> messages = new HashMap<AndroidCompilerMessageKind, List<String>>();
  messages.put(AndroidCompilerMessageKind.ERROR, new ArrayList<String>());
  messages.put(AndroidCompilerMessageKind.WARNING, new ArrayList<String>());
  messages.put(AndroidCompilerMessageKind.INFORMATION, new ArrayList<String>());

  final Pair<PrivateKey, X509Certificate> pair = getPrivateKeyAndCertificate(messagePrefix, messages, keyAlias, keyStorePath,
                                                                             keyStorePassword, keyPassword);
  if (pair == null) {
    return messages;
  }
  final String prefix = "Cannot sign artifact " + artifactName + ": ";

  if (artifactFilePath == null) {
    messages.get(AndroidCompilerMessageKind.ERROR).add(prefix + "output path is not specified");
    return messages;
  }

  final File artifactFile = new File(artifactFilePath);
  if (!artifactFile.exists()) {
    messages.get(AndroidCompilerMessageKind.ERROR).add(prefix + "file " + artifactFilePath + " hasn't been generated");
    return messages;
  }
  final String zipAlignPath = getZipAlign(sdkLocation, target);
  final boolean runZipAlign = new File(zipAlignPath).isFile();

  File tmpDir = null;
  try {
    tmpDir = FileUtil.createTempDirectory("android_artifact", "tmp");
    final File tmpArtifact = new File(tmpDir, "tmpArtifact.apk");

    signApk(artifactFile, tmpArtifact, pair.getFirst(), pair.getSecond());

    if (!FileUtil.delete(artifactFile)) {
      messages.get(AndroidCompilerMessageKind.ERROR).add("Cannot delete file " + artifactFile.getPath());
      return messages;
    }

    if (runZipAlign) {
      final String errorMessage = executeZipAlign(zipAlignPath, tmpArtifact, artifactFile);
      if (errorMessage != null) {
        messages.get(AndroidCompilerMessageKind.ERROR).add(messagePrefix + "zip-align: " + errorMessage);
        return messages;
      }
    }
    else {
      messages.get(AndroidCompilerMessageKind.WARNING).add(messagePrefix + AndroidCommonBundle.message(
        "android.artifact.building.cannot.find.zip.align.error"));
      FileUtil.copy(tmpArtifact, artifactFile);
    }
  }
  finally {
    if (tmpDir != null) {
      FileUtil.delete(tmpDir);
    }
  }
  return messages;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:69,代码来源:AndroidCommonUtils.java

示例15: setUp

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
  super.setUp();
  myArtifactsOutput = FileUtil.createTempDirectory("artifactsOutput", null);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:JpsAntArtifactBuilderTaskTest.java


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