FileLocator的方法toFileURL忽略空文件夹 [英] FileLocator's method toFileURL ignores empty folders
问题描述
借助此和此问题我通过从我的插件包复制这个项目,设法在项目中创建了大部分所需的文件结构。
URL templatesURL = Activator.getDefault()。getBundle()。getEntry(TEMPLATES_PATH);
文件templatesFolder = new File(FileLocator.toFileURL(templatesURL).getPath());
copyFiles(templatesFolder,project,monitor);我有两个文件夹 TEMPLATES_PATH +\test\java
$ / / code>其中没有文件。我想要创建这些也是,但他们不。调查导致我进入OSGi提取包的内容的文件夹: C:\eclipse\configuration\org .eclipse.osgi\< number> \0\.cp
被提取!我可以创建一个空文件test\java\.touch
或手动创建文件夹
IFolder testFolder = project.getFolder(new Path(test));
testFolder.create(true,true monitor);
testFolder.getFolder(new Path(java))。create(true,true monitor);
我可以使用两种方式之一获得所需的结构,但我想知道:是否有一种使 FileLocator
提取文件夹的方法
解决方案看起来像构建目录的代码是 org.eclipse.osgi.storage.bundlefile.ZipBundleFile
。
我不看到任何方式影响它对空目录的作用。
With aid of this and this questions I managed to create the most of the desired file structure in a project by copying this from my plugin bundle.
URL templatesURL = Activator.getDefault().getBundle().getEntry(TEMPLATES_PATH);
File templatesFolder = new File(FileLocator.toFileURL(templatesURL).getPath());
copyFiles(templatesFolder, project, monitor);
I have two folders TEMPLATES_PATH + "\test\java"
with no files in them. I want these to be created as well, but they don't. Investigations led me to the folder where OSGi extracts the contents of the bundle:
C:\eclipse\configuration\org.eclipse.osgi\<number>\0\.cp
The folders aren't being extracted! I could either create an empty file "test\java\.touch"
or create the folders manually with
IFolder testFolder = project.getFolder(new Path("test"));
testFolder.create(true, true monitor);
testFolder.getFolder(new Path("java")).create(true, true monitor);
I can get the desired structure using one of the both ways but I would like to know: is there a way to make FileLocator
extract the folders?
解决方案 Looks like the code that builds the directories is org.eclipse.osgi.storage.bundlefile.ZipBundleFile
.
I don't see any way to influence what it does with empty directories.
这篇关于FileLocator的方法toFileURL忽略空文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!