Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 96704 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/ui/internal/wizards/datatransfer/TarLeveledStructureProvider.java (-32 / +31 lines)
Lines 56-93 Link Here
56
	}
56
	}
57
57
58
	/**
58
	/**
59
	 * Adds the specified child to the internal collection of the parent's
59
	 * Creates a new container tar entry with the specified name, iff it has 
60
	 * children.
60
	 * not already been created. If the parent of the given element does not
61
	 */
61
	 * already exist it will be recursively created as well.
62
	protected void addToChildren(TarEntry parent, TarEntry child) {
62
	 * @param pathname The path representing the container
63
		List childList = (List) children.get(parent);
63
	 * @return The element represented by this pathname (it may have already existed)
64
		if (childList == null) {
64
	 */
65
			childList = new ArrayList();
65
	protected TarEntry createContainer(IPath pathname) {
66
			children.put(parent, childList);
66
		TarEntry existingEntry = (TarEntry) directoryEntryCache.get(pathname);
67
		}
67
		if (existingEntry != null)
68
68
			return existingEntry;
69
		childList.add(child);
70
	}
71
72
	/**
73
	 * Creates a new container tar entry with the specified name, iff it has not
74
	 * already been created.
75
	 */
76
	protected void createContainer(IPath pathname) {
77
		if (directoryEntryCache.containsKey(pathname))
78
			return;
79
69
80
		TarEntry parent;
70
		TarEntry parent;
81
		if (pathname.segmentCount() == 1)
71
		if (pathname.segmentCount() == 1)
82
			parent = root;
72
			parent = root;
83
		else
73
		else
84
			parent = (TarEntry) directoryEntryCache.get(pathname
74
			parent = createContainer(pathname.removeLastSegments(1));
85
					.removeLastSegments(1));
86
87
		TarEntry newEntry = new TarEntry(pathname.toString());
75
		TarEntry newEntry = new TarEntry(pathname.toString());
88
		newEntry.setFileType(TarEntry.DIRECTORY);
76
		newEntry.setFileType(TarEntry.DIRECTORY);
89
		directoryEntryCache.put(pathname, newEntry);
77
		directoryEntryCache.put(pathname, newEntry);
90
		addToChildren(parent, newEntry);
78
		List childList = new ArrayList();
79
		children.put(newEntry, childList);
80
81
		List parentChildList = (List) children.get(parent);
82
		parentChildList.add(newEntry);
83
		return newEntry;
91
	}
84
	}
92
85
93
	/**
86
	/**
Lines 102-108 Link Here
102
			parent = (TarEntry) directoryEntryCache.get(pathname
95
			parent = (TarEntry) directoryEntryCache.get(pathname
103
					.removeLastSegments(1));
96
					.removeLastSegments(1));
104
97
105
		addToChildren(parent, entry);
98
		List childList = (List) children.get(parent);
99
		childList.add(entry);
106
	}
100
	}
107
101
108
	/*
102
	/*
Lines 183-203 Link Here
183
	 */
177
	 */
184
	protected void initialize() {
178
	protected void initialize() {
185
		children = new HashMap(1000);
179
		children = new HashMap(1000);
186
180
		
181
		children.put(root, new ArrayList());
187
		Enumeration entries = tarFile.entries();
182
		Enumeration entries = tarFile.entries();
188
		while (entries.hasMoreElements()) {
183
		while (entries.hasMoreElements()) {
189
			TarEntry entry = (TarEntry) entries.nextElement();
184
			TarEntry entry = (TarEntry) entries.nextElement();
190
			if (entry.getFileType() == TarEntry.FILE) {
185
			IPath path = new Path(entry.getName()).addTrailingSeparator();
191
				IPath path = new Path(entry.getName()).addTrailingSeparator();
186
			
187
			if (entry.getFileType() == TarEntry.DIRECTORY) 
188
				createContainer(path);
189
			else
190
			{
191
				// Ensure the container structure for all levels above this is initialized
192
				// Once we hit a higher-level container that's already added we need go no further
192
				int pathSegmentCount = path.segmentCount();
193
				int pathSegmentCount = path.segmentCount();
193
194
				createContainer(path.uptoSegment(pathSegmentCount - 1));
194
				for (int i = 1; i < pathSegmentCount; i++)
195
					createContainer(path.uptoSegment(i));
196
				createFile(entry);
195
				createFile(entry);
197
			}
196
			}
198
		}
197
		}
199
	}
198
	}
200
199
	
201
	/*
200
	/*
202
	 * (non-Javadoc) Method declared on IImportStructureProvider
201
	 * (non-Javadoc) Method declared on IImportStructureProvider
203
	 */
202
	 */
(-)src/org/eclipse/ui/internal/wizards/datatransfer/ZipLeveledStructureProvider.java (-30 / +29 lines)
Lines 58-94 Link Here
58
	}
58
	}
59
59
60
	/**
60
	/**
61
	 * Adds the specified child to the internal collection of the parent's
61
	 * Creates a new container zip entry with the specified name, iff it has 
62
	 * children.
62
	 * not already been created. If the parent of the given element does not
63
	 */
63
	 * already exist it will be recursively created as well.
64
	protected void addToChildren(ZipEntry parent, ZipEntry child) {
64
	 * @param pathname The path representing the container
65
		List childList = (List) children.get(parent);
65
	 * @return The element represented by this pathname (it may have already existed)
66
		if (childList == null) {
66
	 */
67
			childList = new ArrayList();
67
	protected ZipEntry createContainer(IPath pathname) {
68
			children.put(parent, childList);
68
		ZipEntry existingEntry = (ZipEntry) directoryEntryCache.get(pathname);
69
		}
69
		if (existingEntry != null)
70
70
			return existingEntry;
71
		childList.add(child);
72
	}
73
74
	/**
75
	 * Creates a new container zip entry with the specified name, iff it has not
76
	 * already been created.
77
	 */
78
	protected void createContainer(IPath pathname) {
79
		if (directoryEntryCache.containsKey(pathname))
80
			return;
81
71
82
		ZipEntry parent;
72
		ZipEntry parent;
83
		if (pathname.segmentCount() == 1)
73
		if (pathname.segmentCount() == 1)
84
			parent = root;
74
			parent = root;
85
		else
75
		else
86
			parent = (ZipEntry) directoryEntryCache.get(pathname
76
			parent = createContainer(pathname.removeLastSegments(1));
87
					.removeLastSegments(1));
88
89
		ZipEntry newEntry = new ZipEntry(pathname.toString());
77
		ZipEntry newEntry = new ZipEntry(pathname.toString());
90
		directoryEntryCache.put(pathname, newEntry);
78
		directoryEntryCache.put(pathname, newEntry);
91
		addToChildren(parent, newEntry);
79
		List childList = new ArrayList();
80
		children.put(newEntry, childList);
81
82
		List parentChildList = (List) children.get(parent);
83
		parentChildList.add(newEntry);
84
		return newEntry;
92
	}
85
	}
93
86
94
	/**
87
	/**
Lines 103-109 Link Here
103
			parent = (ZipEntry) directoryEntryCache.get(pathname
96
			parent = (ZipEntry) directoryEntryCache.get(pathname
104
					.removeLastSegments(1));
97
					.removeLastSegments(1));
105
98
106
		addToChildren(parent, entry);
99
		List childList = (List) children.get(parent);
100
		childList.add(entry);
107
	}
101
	}
108
102
109
	/*
103
	/*
Lines 191-205 Link Here
191
	protected void initialize() {
185
	protected void initialize() {
192
		children = new HashMap(1000);
186
		children = new HashMap(1000);
193
187
188
		children.put(root, new ArrayList());
194
		Enumeration entries = zipFile.entries();
189
		Enumeration entries = zipFile.entries();
195
		while (entries.hasMoreElements()) {
190
		while (entries.hasMoreElements()) {
196
			ZipEntry entry = (ZipEntry) entries.nextElement();
191
			ZipEntry entry = (ZipEntry) entries.nextElement();
197
			if (!entry.isDirectory()) {
192
			IPath path = new Path(entry.getName()).addTrailingSeparator();
198
				IPath path = new Path(entry.getName()).addTrailingSeparator();
199
				int pathSegmentCount = path.segmentCount();
200
193
201
				for (int i = 1; i < pathSegmentCount; i++)
194
			if (entry.isDirectory())
202
					createContainer(path.uptoSegment(i));
195
				createContainer(path);
196
			else
197
			{
198
				// Ensure the container structure for all levels above this is initialized
199
				// Once we hit a higher-level container that's already added we need go no further
200
				int pathSegmentCount = path.segmentCount();
201
				createContainer(path.uptoSegment(pathSegmentCount - 1));
203
				createFile(entry);
202
				createFile(entry);
204
			}
203
			}
205
		}
204
		}

Return to bug 96704