FileLocator toFileURL method ignores empty folders

With this and these questions, I was able to create most of the desired file structure in the project by copying this from my plugin.

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" in which there are no files. I want them to be created too, but they do not. Research led me to a folder where OSGi fetches the contents of the package:

 C:\eclipse\configuration\org.eclipse.osgi\<number>\0\.cp 

Folders are not extracted! I could create an empty file "test\java\.touch" or create folders manually using

 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 two methods, but I would like to know: is there a way to make FileLocator extract folders?

+1
source share
1 answer

It looks like the directory-creating code is org.eclipse.osgi.storage.bundlefile.ZipBundleFile .

I see no way to influence what it does with empty directories.

+1
source

Source: https://habr.com/ru/post/1390085/


All Articles