Posts Tagged ‘filesystem

29
Dec
07

Eclipse: Parallel Source Hirarchies

My current endeavor into eclipse plugin development requires storing metadata in a file-structure very similar to the existing one. For each source file I create a ’shadow’ meta-file.

This way, **/myproject/src/model/databaseapp.java becomes **/myproject/META/src/model/databaseapp.java.meta

Path and Resource manipulation is so great in eclipse, I was able to easily do that:

private IPath createMetaDirectoryPath(IResource file)
{
IPath projectPath = file.getProject().getLocation();
IPath fileRelativePath = file.getProjectRelativePath();

   return projectPath.append(Strings.METADATA_DIR).append(fileRelativePath)
.addFileExtension(Strings.METADATA_FILE_EXT);
}

I use getProjectRelative() to get the middle part of the path, append my own path to the project path via Resource.getProject().getLocation(), and then glue it all togather.