Bug 73962 [IDE] NPE in CopyFilesAndFoldersOperation when overwriting existing folder
bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/ImportOperation.java
*/
    IContainer getDestinationContainerFor(Object fileSystemObject)
            throws CoreException {
        IPath pathname = new Path(provider.getFullPath(fileSystemObject));
        if (createContainerStructure)
            return createContainersFor(pathname.removeLastSegments(1));
        if (source == fileSystemObject)
                return null;
        IPath sourcePath = new Path(provider.getFullPath(source));
        IPath destContainerPath = pathname.removeLastSegments(1);
        IPath relativePath = destContainerPath.removeFirstSegments(
                sourcePath.segmentCount()).setDevice(null);
        return createContainersFor(relativePath);
        
    }
    /**
     * Returns the resource either casted to or adapted to an IFile. 
     * 
     * @param resource resource to cast/adapt
     * @return the resource either casted to or adapted to an IFile.
     * 	<code>null</code> if the resource does not adapt to IFile 
     */
    IFile getFile(IResource resource) {
        if (resource instanceof IFile) {
            return (IFile) resource;
        }
        Object adapted = ((IAdaptable) resource).getAdapter(IFile.class);
        if(adapted == null)
        	return null;
        return (IFile) adapted;