本文整理汇总了Java中com.intellij.openapi.util.io.FileUtil.getTempDirectory方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtil.getTempDirectory方法的具体用法?Java FileUtil.getTempDirectory怎么用?Java FileUtil.getTempDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.util.io.FileUtil
的用法示例。
在下文中一共展示了FileUtil.getTempDirectory方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initRepository
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@NotNull
@Override
protected Repository initRepository(@NotNull String name) {
String tempDirectory = FileUtil.getTempDirectory();
String root = tempDirectory + "/" + name;
assertTrue(new File(root).mkdirs());
HgPlatformTest.initRepo(root);
touch("a.txt");
hg("add a.txt");
hg("commit -m another");
hg("up -r 0");
ProjectLevelVcsManagerImpl vcsManager = (ProjectLevelVcsManagerImpl)ProjectLevelVcsManager.getInstance(myProject);
vcsManager.setDirectoryMapping(root, HgVcs.VCS_NAME);
VirtualFile file = LocalFileSystem.getInstance().findFileByIoFile(new File(root));
HgRepository repository = HgUtil.getRepositoryManager(myProject).getRepositoryForRoot(file);
assertNotNull("Couldn't find repository for root " + root, repository);
return repository;
}
示例2: getOrCreateTempDir
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Nullable
private static File getOrCreateTempDir() {
File tmpDir = new File(FileUtil.getTempDirectory());
File dir = new File(tmpDir, TEMP_DIR_NAME);
if (dir.isDirectory() || dir.mkdirs()) {
return dir;
}
try {
return FileUtil.createTempDirectory(tmpDir, TEMP_DIR_NAME, null);
} catch (IOException ignored) {
LOG.warn("Can't create '" + TEMP_DIR_NAME + "' temporary directory.");
}
return null;
}
示例3: testDocumentReuse
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public void testDocumentReuse() throws IOException {
File classFile = new File(FileUtil.getTempDirectory(), "ReuseTest.class");
FileUtil.writeToFile(classFile, "");
VirtualFile vFile = StandardFileSystems.local().findFileByPath(classFile.getPath());
assertNotNull(classFile.getPath(), vFile);
PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(vFile);
assertNotNull(psiFile);
String testDir = getTestDataDir();
FileUtil.copy(new File(testDir, "pkg/ReuseTestV1.class"), classFile);
vFile.refresh(false, false);
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
String text1 = psiFile.getText();
assertTrue(text1, text1.contains("private int f1"));
assertFalse(text1, text1.contains("private int f2"));
Document doc1 = FileDocumentManager.getInstance().getCachedDocument(vFile);
assertNotNull(doc1);
assertSame(doc1, PsiDocumentManager.getInstance(getProject()).getDocument(psiFile));
FileUtil.copy(new File(testDir, "pkg/ReuseTestV2.class"), classFile);
vFile.refresh(false, false);
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
String text2 = psiFile.getText();
assertTrue(text2, text2.contains("private int f1"));
assertTrue(text2, text2.contains("private int f2"));
Document doc2 = FileDocumentManager.getInstance().getCachedDocument(vFile);
assertNotNull(doc2);
assertSame(doc2, PsiDocumentManager.getInstance(getProject()).getDocument(psiFile));
}
示例4: doStuff
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
private void doStuff(String rootDir, String itemRepr, String itemName) throws FileNotFoundException {
String patternName = getTestDataPath() + getTestRoot() + getTestName(true) + "/after/" + itemName;
File patternFile = new File(patternName);
PrintWriter writer;
if (!patternFile.exists()) {
writer = new PrintWriter(new FileOutputStream(patternFile));
try {
writer.print(itemRepr);
}
finally {
writer.close();
}
System.out.println("Pattern not found, file " + patternName + " created.");
LocalFileSystem.getInstance().refreshAndFindFileByIoFile(patternFile);
}
File graFile = new File(FileUtil.getTempDirectory() + File.separator + rootDir + File.separator + itemName);
writer = new PrintWriter(new FileOutputStream(graFile));
try {
writer.print(itemRepr);
}
finally {
writer.close();
}
LocalFileSystem.getInstance().refreshAndFindFileByIoFile(graFile);
FileDocumentManager.getInstance().saveAllDocuments();
}
示例5: ensureTempDirCreated
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
private void ensureTempDirCreated() throws IOException {
if (ourTempDir != null) return;
ourTempDir = new File(FileUtil.getTempDirectory(), getTestsTempDir());
FileUtil.delete(ourTempDir);
FileUtil.ensureExists(ourTempDir);
}
示例6: isValidFilename
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
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);
}
示例7: ensureTempDirCreated
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
private static void ensureTempDirCreated() throws IOException {
if (ourTempDir != null) return;
ourTempDir = new File(FileUtil.getTempDirectory(), "gradleTests");
FileUtil.delete(ourTempDir);
FileUtil.ensureExists(ourTempDir);
}
示例8: initRepository
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@NotNull
@Override
protected Repository initRepository(@NotNull String name) {
String tempDirectory = FileUtil.getTempDirectory();
String root = tempDirectory + "/" + name;
assertTrue(new File(root).mkdirs());
GitRepository repository = GitTestUtil.createRepository(getProject(), root);
GitBranchesCollection branches = repository.getBranches();
assertEquals(1, branches.getLocalBranches().size());
return repository;
}
示例9: ensureTempDirCreated
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
private void ensureTempDirCreated() throws IOException {
if (ourTempDir != null) return;
ourTempDir = new File(FileUtil.getTempDirectory(), "mavenTests");
FileUtil.delete(ourTempDir);
FileUtil.ensureExists(ourTempDir);
}
示例10: initCodeGenerator
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
private AsmCodeGenerator initCodeGenerator(final String formFileName, final String className, final String testDataPath) throws Exception {
String tmpPath = FileUtil.getTempDirectory();
String formPath = testDataPath + formFileName;
String javaPath = testDataPath + className + ".java";
final int rc = Main.compile(new String[]{"-d", tmpPath, javaPath});
assertEquals(0, rc);
final String classPath = tmpPath + "/" + className + ".class";
final File classFile = new File(classPath);
assertTrue(classFile.exists());
final LwRootContainer rootContainer = loadFormData(formPath);
final AsmCodeGenerator codeGenerator = new AsmCodeGenerator(rootContainer, myClassFinder, myNestedFormLoader, false, new ClassWriter(ClassWriter.COMPUTE_FRAMES));
final FileInputStream classStream = new FileInputStream(classFile);
try {
codeGenerator.patchClass(classStream);
}
finally {
classStream.close();
FileUtil.delete(classFile);
final File[] inners = new File(tmpPath).listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.startsWith(className + "$") && name.endsWith(".class");
}
});
if (inners != null) {
for (File file : inners) FileUtil.delete(file);
}
}
return codeGenerator;
}
示例11: setUp
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
myTestRoot = new File(FileUtil.getTempDirectory(), "testRoot");
myFilesToDelete.add(myTestRoot);
checkTestRootIsEmpty(myTestRoot);
EdtTestUtil.runInEdtAndWait(new ThrowableRunnable<Throwable>() {
@Override
public void run() throws Exception {
GitPlatformTest.super.setUp();
}
});
enableDebugLogging();
myProjectRoot = myProject.getBaseDir();
myProjectPath = myProjectRoot.getPath();
myGitSettings = GitVcsSettings.getInstance(myProject);
myGitSettings.getAppSettings().setPathToGit(GitExecutor.PathHolder.GIT_EXECUTABLE);
myDialogManager = (TestDialogManager)ServiceManager.getService(DialogManager.class);
myVcsNotifier = (TestVcsNotifier)ServiceManager.getService(myProject, VcsNotifier.class);
myGitRepositoryManager = GitUtil.getRepositoryManager(myProject);
myPlatformFacade = ServiceManager.getService(myProject, GitPlatformFacade.class);
myGit = ServiceManager.getService(myProject, Git.class);
myVcs = ObjectUtils.assertNotNull(GitVcs.getInstance(myProject));
myVcs.doActivate();
GitTestUtil.assumeSupportedGitVersion(myVcs);
addSilently();
removeSilently();
}
示例12: setUp
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
root = new File(FileUtil.getTempDirectory());
}
示例13: testEventsAfterFileModifications
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public void testEventsAfterFileModifications() throws Exception {
File root = new File(FileUtil.getTempDirectory());
File dir1 = new File(root, "dir1");
assertTrue(dir1.mkdirs());
VirtualFile vDir1 = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(dir1);
assertNotNull(vDir1);
Module moduleA = createModule("a.iml");
myModuleRootListener.reset();
ModuleRootModificationUtil.addContentRoot(moduleA, vDir1.getPath());
UIUtil.dispatchAllInvocationEvents();
assertEventsCount(1);
assertSameElements(ModuleRootManager.getInstance(moduleA).getContentRoots(), vDir1);
delete(vDir1);
assertEventsCount(1);
assertEmpty(ModuleRootManager.getInstance(moduleA).getContentRoots());
File dir2 = new File(root, "dir2");
assertTrue(dir2.mkdirs());
VirtualFile vDir2 = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(dir2);
assertNotNull(vDir2);
rename(vDir2, "dir1");
assertEventsCount(1);
assertSameElements(ModuleRootManager.getInstance(moduleA).getContentRoots(), vDir2);
// when the existing root is renamed, it remains a root
rename(vDir2, "dir2");
assertEventsCount(0);
assertSameElements(ModuleRootManager.getInstance(moduleA).getContentRoots(), vDir2);
// and event if it is moved, it's still a root
File subdir = new File(root, "subdir");
assertTrue(subdir.mkdirs());
VirtualFile vSubdir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(subdir);
assertNotNull(vSubdir);
move(vDir2, vSubdir);
assertEventsCount(0);
assertSameElements(ModuleRootManager.getInstance(moduleA).getContentRoots(), vDir2);
}
示例14: getFileName
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
protected String getFileName() {
return FileUtil.getTempDirectory() + File.separatorChar + getName();
}