rabejens
rabejens

Reputation: 8142

Eclipse: How to save custom files to Workspace .metadata folder?

I want to save settings from a plugin in the .metadata/.plugins/com.example.myplugin folder. When I use the preferences, they are saved there, but I want to save custom files there. Now, the Eclipse documentation says I should never write files there using file operations but only with platform commands.

So, how do I save custom workspace metadata the correct way?

Upvotes: 1

Views: 915

Answers (1)

greg-449
greg-449

Reputation: 111218

That location is the plug-in's 'state location' you get it using:

Bundle bundle = ... your plug-in's bundle

IPath stateLoc = Platform.getStateLocation(bundle);

It is entirely up to your plug-in to manage this folder. You do use ordinary Java file I/O in this folder.

One way to get your Bundle is:

Bundle bundle = FrameworkUtil.getBundle(getClass());

Upvotes: 7

Related Questions