Java Code Examples for com.intellij.openapi.vfs.VfsUtil#createDirectories()
The following examples show how to use
com.intellij.openapi.vfs.VfsUtil#createDirectories() .
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: MuleDomainMavenProjectBuilderHelper.java From mule-intellij-plugins with Apache License 2.0 | 6 votes |
public void configure(final Project project, final MavenId projectId, final String muleVersion, final VirtualFile root) { try { //Create mule folders. final VirtualFile appDirectory = VfsUtil.createDirectories(root.getPath() + "/src/main/domain"); final VirtualFile resources = VfsUtil.createDirectories(root.getPath() + "/src/main/resources"); final VirtualFile muleConfigFile = createMuleConfigFile(project, projectId, appDirectory); createMuleDeployPropertiesFile(project, projectId, appDirectory); createPomFile(project, projectId, muleVersion, root); // execute when current dialog is closed (e.g. Project Structure) MavenUtil.invokeLater(project, ModalityState.NON_MODAL, () -> EditorHelper.openInEditor(getPsiFile(project, muleConfigFile))); } catch (IOException e) { e.printStackTrace(); } }
Example 2
Source File: HeavyIdeaTestFixtureImpl.java From consulo with Apache License 2.0 | 6 votes |
@Override public PsiFile addFileToProject(@NonNls String rootPath, @NonNls final String relativePath, @NonNls final String fileText) throws IOException { final VirtualFile dir = VfsUtil.createDirectories(rootPath + "/" + PathUtil.getParentPath(relativePath)); final VirtualFile[] virtualFile = new VirtualFile[1]; new WriteCommandAction.Simple(getProject()) { @Override protected void run() throws Throwable { virtualFile[0] = dir.createChildData(this, StringUtil.getShortName(relativePath, '/')); VfsUtil.saveText(virtualFile[0], fileText); } }.execute(); return ApplicationManager.getApplication().runReadAction(new Computable<PsiFile>() { public PsiFile compute() { return PsiManager.getInstance(getProject()).findFile(virtualFile[0]); } }); }
Example 3
Source File: ProjectWizardUtil.java From consulo with Apache License 2.0 | 6 votes |
public static boolean createDirectoryIfNotExists(final String promptPrefix, String directoryPath, boolean promptUser) { File dir = new File(directoryPath); if (!dir.exists()) { if (promptUser) { final int answer = Messages.showOkCancelDialog(IdeBundle.message("promot.projectwizard.directory.does.not.exist", promptPrefix, dir.getPath(), ApplicationNamesInfo.getInstance().getFullProductName()), IdeBundle.message("title.directory.does.not.exist"), Messages.getQuestionIcon()); if (answer != 0) { return false; } } try { VfsUtil.createDirectories(dir.getPath()); } catch (IOException e) { Messages.showErrorDialog(IdeBundle.message("error.failed.to.create.directory", dir.getPath()), CommonBundle.getErrorTitle()); return false; } } return true; }
Example 4
Source File: PathsVerifier.java From consulo with Apache License 2.0 | 6 votes |
@javax.annotation.Nullable private VirtualFile makeSureParentPathExists(final String[] pieces) throws IOException { VirtualFile child = myBaseDirectory; final int size = (pieces.length - 1); for (int i = 0; i < size; i++) { final String piece = pieces[i]; if (StringUtil.isEmptyOrSpaces(piece)) { continue; } if ("..".equals(piece)) { child = child.getParent(); continue; } VirtualFile nextChild = child.findChild(piece); if (nextChild == null) { nextChild = VfsUtil.createDirectories(child.getPath() + '/' + piece); myCreatedDirectories.add(nextChild); } child = nextChild; } return child; }
Example 5
Source File: MuleMavenProjectBuilderHelper.java From mule-intellij-plugins with Apache License 2.0 | 5 votes |
public void configure(final Project project, final MavenId projectId, final String muleVersion, final VirtualFile root, @Nullable MavenId parentId) { try { //Create mule folders. final VirtualFile appDirectory = VfsUtil.createDirectories(root.getPath() + "/src/main/app"); final VirtualFile resources = VfsUtil.createDirectories(root.getPath() + "/src/main/resources"); createLog4J(project, projectId, resources); final VirtualFile muleConfigFile = createMuleConfigFile(project, projectId, appDirectory); createMuleDeployPropertiesFile(project, projectId, appDirectory); createMuleAppPropertiesFiles(project, appDirectory); VfsUtil.createDirectories(root.getPath() + "/src/main/api"); //MUnit support VfsUtil.createDirectories(root.getPath() + "/src/test/munit"); final VirtualFile testResources = VfsUtil.createDirectories(root.getPath() + "/src/test/resources"); createLog4JTest(project, projectId, testResources); if (parentId == null) createPomFile(project, projectId, muleVersion, root); else createModulePomFile(project, projectId, root, parentId); // execute when current dialog is closed (e.g. Project Structure) MavenUtil.invokeLater(project, ModalityState.NON_MODAL, () -> EditorHelper.openInEditor(getPsiFile(project, muleConfigFile))); } catch (IOException e) { e.printStackTrace(); } }
Example 6
Source File: RPiJavaModuleBuilder.java From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 | 5 votes |
/** * Setup module with PI4J * * @param module * @throws ConfigurationException */ @SneakyThrows(IOException.class) @Override protected void setupModule(Module module) throws ConfigurationException { super.setupModule(module); if(!noLibrariesNeeded) { final String libPath = module.getProject().getBasePath() + File.separator + "lib"; VfsUtil.createDirectories(libPath); File outputFiles = new File(libPath); FileUtilities.unzip(getClass().getResourceAsStream("/pi4j.zip"), outputFiles.getAbsolutePath()); jarsToAdd = outputFiles.listFiles(); } }
Example 7
Source File: FactoryImpl.java From floobits-intellij with Apache License 2.0 | 5 votes |
@Override public IFile createDirectories(String path) { VirtualFile directory = null; try { directory = VfsUtil.createDirectories(path); } catch (IOException e) { Flog.error(e); } if (directory == null) { Flog.warn("Failed to create directories %s %s", path); return null; } return new FileImpl(directory); }
Example 8
Source File: ScratchFileServiceImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public VirtualFile findFile(@Nonnull RootType rootType, @Nonnull String pathName, @Nonnull Option option) throws IOException { ApplicationManager.getApplication().assertReadAccessAllowed(); String fullPath = getRootPath(rootType) + "/" + pathName; if (option != Option.create_new_always) { VirtualFile file = LocalFileSystem.getInstance().findFileByPath(fullPath); if (file != null && !file.isDirectory()) return file; if (option == Option.existing_only) return null; } String ext = PathUtil.getFileExtension(pathName); String fileNameExt = PathUtil.getFileName(pathName); String fileName = StringUtil.trimEnd(fileNameExt, ext == null ? "" : "." + ext); AccessToken token = ApplicationManager.getApplication().acquireWriteActionLock(getClass()); try { VirtualFile dir = VfsUtil.createDirectories(PathUtil.getParentPath(fullPath)); if (option == Option.create_new_always) { return VfsUtil.createChildSequent(LocalFileSystem.getInstance(), dir, fileName, StringUtil.notNullize(ext)); } else { return dir.createChildData(LocalFileSystem.getInstance(), fileNameExt); } } finally { token.finish(); } }