本文整理汇总了Java中com.intellij.openapi.util.io.FileUtil.isJarOrZip方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtil.isJarOrZip方法的具体用法?Java FileUtil.isJarOrZip怎么用?Java FileUtil.isJarOrZip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.util.io.FileUtil
的用法示例。
在下文中一共展示了FileUtil.isJarOrZip方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addLibraries
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
private static void addLibraries(Collection<URL> classPath, File fromDir, URL selfRootUrl) throws MalformedURLException {
File[] files = fromDir.listFiles();
if (files == null) return;
for (File file : files) {
if (FileUtil.isJarOrZip(file)) {
URL url = file.toURI().toURL();
if (!selfRootUrl.equals(url)) {
classPath.add(url);
}
}
}
}
示例2: loadDescriptor
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Nullable
public static IdeaPluginDescriptorImpl loadDescriptor(@NotNull final File file, @NotNull String fileName) {
IdeaPluginDescriptorImpl descriptor = null;
if (file.isDirectory()) {
descriptor = loadDescriptorFromDir(file, fileName);
if (descriptor == null) {
File libDir = new File(file, "lib");
if (!libDir.isDirectory()) {
return null;
}
final File[] files = libDir.listFiles();
if (files == null || files.length == 0) {
return null;
}
Arrays.sort(files, new Comparator<File>() {
@Override
public int compare(@NotNull File o1, @NotNull File o2) {
if (o2.getName().startsWith(file.getName())) return Integer.MAX_VALUE;
if (o1.getName().startsWith(file.getName())) return -Integer.MAX_VALUE;
if (o2.getName().startsWith("resources")) return -Integer.MAX_VALUE;
if (o1.getName().startsWith("resources")) return Integer.MAX_VALUE;
return 0;
}
});
for (final File f : files) {
if (FileUtil.isJarOrZip(f)) {
descriptor = loadDescriptorFromJar(f, fileName);
if (descriptor != null) {
descriptor.setPath(file);
break;
}
// getLogger().warn("Cannot load descriptor from " + f.getName() + "");
}
else if (f.isDirectory()) {
IdeaPluginDescriptorImpl descriptor1 = loadDescriptorFromDir(f, fileName);
if (descriptor1 != null) {
if (descriptor != null) {
getLogger().info("Cannot load " + file + " because two or more plugin.xml's detected");
return null;
}
descriptor = descriptor1;
descriptor.setPath(file);
}
}
}
}
}
else if (StringUtil.endsWithIgnoreCase(file.getName(), ".jar") && file.exists()) {
descriptor = loadDescriptorFromJar(file, fileName);
}
if (descriptor != null) {
resolveOptionalDescriptors(fileName, descriptor, new Function<String, IdeaPluginDescriptorImpl>() {
@Override
public IdeaPluginDescriptorImpl fun(String optionalDescriptorName) {
IdeaPluginDescriptorImpl optionalDescriptor = loadDescriptor(file, optionalDescriptorName);
if (optionalDescriptor == null && !FileUtil.isJarOrZip(file)) {
for (URL url : getClassLoaderUrls()) {
if ("file".equals(url.getProtocol())) {
optionalDescriptor = loadDescriptor(new File(decodeUrl(url.getFile())), optionalDescriptorName);
if (optionalDescriptor != null) {
break;
}
}
}
}
return optionalDescriptor;
}
});
}
return descriptor;
}