325733 and 354346  with an additional small modification for other test cases which were not previously run
diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/flat/VirtualComponentFlattenUtility.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/flat/VirtualComponentFlattenUtility.java
index eb001ac..7b3cdd6 100644
--- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/flat/VirtualComponentFlattenUtility.java
+++ b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/flat/VirtualComponentFlattenUtility.java
@@ -106,19 +106,21 @@
 	
 	public void addFile(IVirtualComponent current, IPath path, IAdaptable file) {
 		IVirtualFile vf = (IVirtualFile)file.getAdapter(IVirtualFile.class);
-		String vfName = vf.getName();
 		IFile f = (IFile)file.getAdapter(IFile.class);
 		IFlatFile mf = null;
+		String vfName = null;
+		if( vf != null && vf.getName() != null )
+			vfName = vf.getName();
 		if( f != null )
-			 mf = new FlatFile(f, vfName, path);
+			 mf = new FlatFile(f, vfName == null ? f.getName() : vfName, path);
 		else {
 			File f2 = (File)file.getAdapter(File.class);
 			if( f2 != null )
-				mf = new FlatFile(f2, vfName, path.makeRelative());
+				mf = new FlatFile(f2, vfName == null ? f2.getName() : vfName, path.makeRelative());
 		}
 		if( mf != null ) {
 			if (handler == null || handler.shouldAddComponentFile(current, mf)) {
-				if( mf.getModuleRelativePath().isEmpty()) {
+				if( mf.getModuleRelativePath().segmentCount() == 0) {
 					members.remove(mf);
 					members.add(mf);
 				}