本文整理匯總了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);
}
示例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));
}
示例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);
}
}
示例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);
}
}
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
});
}
示例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;
}
示例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);
}
}
示例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."));
}
示例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);
}
}
示例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
}
}
示例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;
}
示例15: setUp
import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
@Override
protected void setUp() throws Exception {
super.setUp();
myArtifactsOutput = FileUtil.createTempDirectory("artifactsOutput", null);
}