package fr.inria.diverse.commons.eclipse.resources;

import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;

public class IFolderUtils {

	/**
	 * Recursively creates parent IFolder if required
	 * @param folder
	 * @param force
	 * @param local
	 * @param monitor
	 * @throws CoreException
	 */
	public static void create(IFolder folder, boolean force, boolean local, IProgressMonitor monitor) throws CoreException{
		if(folder.getParent() instanceof IFolder && !folder.getParent().exists()){
			create((IFolder) folder.getParent(), force, local, monitor);
		}
		folder.create(force, local, monitor);
	}
	
	public static void createFolder(String path, IProject project, IProgressMonitor monitor) throws CoreException {
		String[] strings = path.split("/");
		IContainer currentContainer = project;
		for ( String s : strings ) {
			IFolder folder = currentContainer.getFolder( new Path(s) );
			folder.create(true, true, monitor);
			currentContainer = folder;
		}
	}
}

@@ -349,16 +349,56 @@
 %7B%0A%0A%09/**%0A
+%09 * Create IFolder if it doesn't exists%0A
 %09 * Recu
@@ -663,16 +663,46 @@
 eption%7B%0A
+%09%09if(folder.exists()) return;%0A
 %09%09if(fol

make sure folder creation doesn't fails if the folder already exists