本文整理汇总了Java中com.intellij.openapi.vfs.VfsUtil.createDirectoryIfMissing方法的典型用法代码示例。如果您正苦于以下问题:Java VfsUtil.createDirectoryIfMissing方法的具体用法?Java VfsUtil.createDirectoryIfMissing怎么用?Java VfsUtil.createDirectoryIfMissing使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.vfs.VfsUtil
的用法示例。
在下文中一共展示了VfsUtil.createDirectoryIfMissing方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createChildFile
import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
public static void createChildFile(@NotNull VirtualFile taskDir, @NotNull String name, @NotNull String text) throws IOException {
String newDirectories = null;
String fileName = name;
VirtualFile dir = taskDir;
if (name.contains("/")) {
int pos = name.lastIndexOf("/");
fileName = name.substring(pos + 1);
newDirectories = name.substring(0, pos);
}
if (newDirectories != null) {
dir = VfsUtil.createDirectoryIfMissing(taskDir, newDirectories);
}
if (dir != null) {
VirtualFile virtualTaskFile = dir.findChild(fileName);
if (virtualTaskFile == null) {
virtualTaskFile = dir.createChildData(taskDir, fileName);
}
if (EduUtils.isImage(name)) {
virtualTaskFile.setBinaryContent(Base64.decodeBase64(text));
}
else {
VfsUtil.saveText(virtualTaskFile, text);
}
}
}
示例2: getOrCreateDestinationPath
import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
private static VirtualFile getOrCreateDestinationPath(VirtualFile rootDirectory, String destinationPath) {
try {
return VfsUtil.createDirectoryIfMissing(rootDirectory, destinationPath);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
示例3: createLesson
import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
public static void createLesson(@NotNull final Lesson lesson, @NotNull final VirtualFile courseDir) throws IOException {
if (EduNames.PYCHARM_ADDITIONAL.equals(lesson.getName())) {
createAdditionalFiles(lesson, courseDir);
}
else {
String lessonDirName = EduNames.LESSON + Integer.toString(lesson.getIndex());
VirtualFile lessonDir = VfsUtil.createDirectoryIfMissing(courseDir, lessonDirName);
final List<Task> taskList = lesson.getTaskList();
for (int i = 1; i <= taskList.size(); i++) {
Task task = taskList.get(i - 1);
task.setIndex(i);
createTask(task, lessonDir);
}
}
}
示例4: run
import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
@Override
protected void run(@NotNull Result<Object> result) throws Throwable {
File moduleLocation = GradleUtil.getModuleDefaultPath(myProject.getBaseDir(), myGradlePath);
try {
VirtualFile moduleRoot = VfsUtil.createDirectoryIfMissing(moduleLocation.getAbsolutePath());
VirtualFile sourceFile = VfsUtil.findFileByIoFile(myArchivePath, true);
if (sourceFile != null && moduleRoot != null) {
if (myMove) {
sourceFile.move(this, moduleRoot);
}
else {
VfsUtil.copy(this, sourceFile, moduleRoot);
}
VirtualFile buildGradle = moduleRoot.createChildData(this, SdkConstants.FN_BUILD_GRADLE);
VfsUtil.saveText(buildGradle, getBuildGradleText(myArchivePath));
if (mySettingsFile == null) {
mySettingsFile = GradleSettingsFile.getOrCreate(myProject);
}
mySettingsFile.addModule(myGradlePath, VfsUtilCore.virtualToIoFile(moduleRoot));
for (Module module : myModulesToAddDependency) {
addDependency(module, myGradlePath);
}
}
}
catch (IOException e) {
Logger.getInstance(WrapArchiveWizardPath.class).error(e);
}
}
示例5: suggestParentDirectoryForAppEngineWebXml
import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
@Nullable
@Override
public VirtualFile suggestParentDirectoryForAppEngineWebXml(@NotNull Module module, @NotNull ModifiableRootModel rootModel) {
final VirtualFile root = ArrayUtil.getFirstElement(rootModel.getContentRoots());
if (root != null) {
try {
return VfsUtil.createDirectoryIfMissing(root, "WEB-INF");
}
catch (IOException e) {
LOG.info(e);
return null;
}
}
return null;
}
示例6: createTask
import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
public static void createTask(@NotNull final Task task, @NotNull final VirtualFile lessonDir) throws IOException {
String name = EduNames.TASK + Integer.toString(task.getIndex());
VirtualFile taskDir = VfsUtil.createDirectoryIfMissing(lessonDir, name);
createTaskContent(task, taskDir);
}