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


Java FileUtil.ensureCanCreateFile方法代码示例

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


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

示例1: createProjectJarSubFile

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@NotNull
protected VirtualFile createProjectJarSubFile(String relativePath, Pair<ByteSequence, String>... contentEntries) throws IOException {
  assertTrue("Use 'jar' extension for JAR files: '" + relativePath + "'", FileUtilRt.extensionEquals(relativePath, "jar"));
  File f = new File(getProjectPath(), relativePath);
  FileUtil.ensureExists(f.getParentFile());
  FileUtil.ensureCanCreateFile(f);
  final boolean created = f.createNewFile();
  if (!created) {
    throw new AssertionError("Unable to create the project sub file: " + f.getAbsolutePath());
  }

  Manifest manifest = new Manifest();
  manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
  JarOutputStream target = new JarOutputStream(new FileOutputStream(f), manifest);
  for (Pair<ByteSequence, String> contentEntry : contentEntries) {
    addJarEntry(contentEntry.first.getBytes(), contentEntry.second, target);
  }
  target.close();

  final VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(f);
  assertNotNull(virtualFile);
  final VirtualFile jarFile = JarFileSystem.getInstance().getJarRootForLocalFile(virtualFile);
  assertNotNull(jarFile);
  return jarFile;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:ExternalSystemTestCase.java

示例2: uninstall

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public void uninstall(@NotNull List<PyPackage> packages) throws ExecutionException {
  final List<String> args = new ArrayList<String>();
  try {
    args.add(UNINSTALL);
    boolean canModify = true;
    for (PyPackage pkg : packages) {
      if (canModify) {
        final String location = pkg.getLocation();
        if (location != null) {
          canModify = FileUtil.ensureCanCreateFile(new File(location));
        }
      }
      args.add(pkg.getName());
    }
    getHelperResult(PACKAGING_TOOL, args, !canModify, true, null);
  }
  catch (PyExecutionException e) {
    throw new PyExecutionException(e.getMessage(), "pip", args, e.getStdout(), e.getStderr(), e.getExitCode(), e.getFixes());
  }
  finally {
    clearCaches();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:PyPackageManagerImpl.java

示例3: createProjectSubFile

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
protected VirtualFile createProjectSubFile(String relativePath) throws IOException {
  File f = new File(getProjectPath(), relativePath);
  FileUtil.ensureExists(f.getParentFile());
  FileUtil.ensureCanCreateFile(f);
  final boolean created = f.createNewFile();
  if(!created) {
    throw new AssertionError("Unable to create the project sub file: " + f.getAbsolutePath());
  }
  return LocalFileSystem.getInstance().refreshAndFindFileByIoFile(f);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:ExternalSystemTestCase.java

示例4: saveExtensions

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
private static void saveExtensions(Map<String, Set<Plugin>> extensions) throws IOException {
  File plugins = getExtensionsFile();
  if (!plugins.isFile()) {
    FileUtil.ensureCanCreateFile(plugins);
  }
  JDOMUtil.writeDocument(new Document(XmlSerializer.serialize(new KnownExtensions(extensions))), plugins, "\n");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:PluginsAdvertiser.java

示例5: 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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:FileTemplateConfigurable.java

示例6: processLibrariesAndJpsPlugins

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
private static void processLibrariesAndJpsPlugins(final File jarFile, final File zipFile, final String pluginName,
                                                  final Set<Library> libs,
                                                  Map<Module, String> jpsModules, final ProgressIndicator progressIndicator) throws IOException {
  if (FileUtil.ensureCanCreateFile(zipFile)) {
    ZipOutputStream zos = null;
    try {
      zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipFile)));
      addStructure(pluginName, zos);
      addStructure(pluginName + "/" + MIDDLE_LIB_DIR, zos);
      final String entryName = pluginName + JAR_EXTENSION;
      ZipUtil.addFileToZip(zos, jarFile, getZipPath(pluginName, entryName), new HashSet<String>(),
                           createFilter(progressIndicator, FileTypeManager.getInstance()));
      for (Map.Entry<Module, String> entry : jpsModules.entrySet()) {
        File jpsPluginJar = jarModulesOutput(Collections.singleton(entry.getKey()), null, null);
        ZipUtil.addFileToZip(zos, jpsPluginJar, getZipPath(pluginName, entry.getValue()), null, null);
      }
      Set<String> usedJarNames = new HashSet<String>();
      usedJarNames.add(entryName);
      Set<VirtualFile> jarredVirtualFiles = new HashSet<VirtualFile>();
      for (Library library : libs) {
        final VirtualFile[] files = library.getFiles(OrderRootType.CLASSES);
        for (VirtualFile virtualFile : files) {
          if (jarredVirtualFiles.add(virtualFile)) {
            if (virtualFile.getFileSystem() instanceof JarFileSystem) {
              addLibraryJar(virtualFile, zipFile, pluginName, zos, usedJarNames, progressIndicator);
            }
            else {
              makeAndAddLibraryJar(virtualFile, zipFile, pluginName, zos, usedJarNames, progressIndicator, library.getName());
            }
          }
        }
      }
    }
    finally {
      if (zos != null) zos.close();
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:PrepareToDeployAction.java

示例7: savePluginsList

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public static void savePluginsList(@NotNull Collection<String> ids, boolean append, @NotNull File plugins) throws IOException {
  if (!plugins.isFile()) {
    FileUtil.ensureCanCreateFile(plugins);
  }
  writePluginsList(ids, new BufferedWriter(new FileWriter(plugins, append)));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:PluginManagerCore.java


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