FileLocator's method toFileURL ignores empty folders

天大地大妈咪最大 提交于 2020-01-03 01:47:12

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/26235880/filelocators-method-tofileurl-ignores-empty-folders

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!