View | Details | Raw Unified | Return to bug 194293 | Differences between
and this patch

Collapse All | Expand All

(-)clientserver/org/eclipse/rse/services/clientserver/archiveutils/ArchiveHandlerManager.java (-2 / +38 lines)
Lines 13-18 Link Here
13
 * 
13
 * 
14
 * Contributors:
14
 * Contributors:
15
 * {Name} (company) - description of contribution.
15
 * {Name} (company) - description of contribution.
16
 * Xuan Chen        (IBM)        - [194293] [Local][Archives] Saving file second time in an Archive Errors
16
 *******************************************************************************/
17
 *******************************************************************************/
17
18
18
package org.eclipse.rse.services.clientserver.archiveutils;
19
package org.eclipse.rse.services.clientserver.archiveutils;
Lines 367-374 Link Here
367
		String newPath = fullVirtualName;
368
		String newPath = fullVirtualName;
368
		if (j != -1)
369
		if (j != -1)
369
		{
370
		{
370
			realPart = fullVirtualName.substring(0, j) + VIRTUAL_SEPARATOR;
371
			try
371
			newPath = fullVirtualName.substring(j + VIRTUAL_SEPARATOR.length());
372
			{
373
				realPart = fullVirtualName.substring(0, j) + VIRTUAL_SEPARATOR;
374
				if (j + VIRTUAL_SEPARATOR.length() < fullVirtualName.length())
375
				{
376
					newPath = fullVirtualName.substring(j + VIRTUAL_SEPARATOR.length());
377
				}
378
				else
379
				{
380
					//This is the special case where fullVirtualName ends with VIRTUAL_SEPARATOR
381
					newPath = "";   //$NON-NLS-1$
382
				}
383
			}
384
			catch (Exception e)
385
			{
386
				e.printStackTrace();
387
			}
372
		}
388
		}
373
		// use only forward slash separator
389
		// use only forward slash separator
374
		newPath = newPath.replace('\\', '/');
390
		newPath = newPath.replace('\\', '/');
Lines 386-391 Link Here
386
		if (newPath.endsWith("/")) newPath = newPath.substring(0, newPath.length() - 1); //$NON-NLS-1$
402
		if (newPath.endsWith("/")) newPath = newPath.substring(0, newPath.length() - 1); //$NON-NLS-1$
387
		return realPart + newPath;
403
		return realPart + newPath;
388
	}
404
	}
405
	
406
	/**
407
	 * Construct the full virtual name of a virtual file from its virtual path and name.
408
	 * @param virtualPath the virtual path of this virtual file
409
	 * @param name the name of this virtual file
410
	 * @return the full virtual name of this virtual file
411
	 */
412
	public static String getFullVirtualName(String virtualPath, String name)
413
	{
414
		String fullVirtualName = null;
415
		if (virtualPath == null || virtualPath.length() == 0)
416
		{
417
			fullVirtualName = name;
418
		}
419
		else
420
		{
421
			fullVirtualName = virtualPath + "/" + name;  //$NON-NLS-1$
422
		}
423
		return fullVirtualName;
424
	}
389
425
390
	/**
426
	/**
391
	 * Disposes of all registered handlers.
427
	 * Disposes of all registered handlers.
(-)clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemZipHandler.java (-5 / +7 lines)
Lines 14-19 Link Here
14
 * Contributors:
14
 * Contributors:
15
 * {Name} (company) - description of contribution.
15
 * {Name} (company) - description of contribution.
16
 * Xuan Chen        (IBM)        - [192741] [Archives] Move a folder from within an Archive doesn't work if > 1 level deep
16
 * Xuan Chen        (IBM)        - [192741] [Archives] Move a folder from within an Archive doesn't work if > 1 level deep
17
 * Xuan Chen        (IBM)        - [194293] [Local][Archives] Saving file second time in an Archive Errors
17
 *******************************************************************************/
18
 *******************************************************************************/
18
19
19
package org.eclipse.rse.services.clientserver.archiveutils;
20
package org.eclipse.rse.services.clientserver.archiveutils;
Lines 907-916 Link Here
907
			for (int i = 0; i < numFiles; i++)
908
			for (int i = 0; i < numFiles; i++)
908
			{		
909
			{		
909
				if (!files[i].exists() || !files[i].canRead()) return false;
910
				if (!files[i].exists() || !files[i].canRead()) return false;
910
				if (exists(virtualPath + "/" + names[i])) //$NON-NLS-1$
911
				String fullVirtualName = ArchiveHandlerManager.getFullVirtualName(virtualPath, names[i]);
912
				if (exists(fullVirtualName)) 
911
				{
913
				{
912
					// sorry, wrong method buddy
914
					// sorry, wrong method buddy
913
					return replace(virtualPath + "/" + names[i], files[i], names[i]); //$NON-NLS-1$
915
					return replace(fullVirtualName, files[i], names[i]); 
914
				}
916
				}
915
			}
917
			}
916
			File outputTempFile;
918
			File outputTempFile;
Lines 2184-2193 Link Here
2184
		virtualPath = ArchiveHandlerManager.cleanUpVirtualPath(virtualPath);
2186
		virtualPath = ArchiveHandlerManager.cleanUpVirtualPath(virtualPath);
2185
		if (!file.isDirectory())
2187
		if (!file.isDirectory())
2186
		{
2188
		{
2187
			if (exists(virtualPath + "/" + name)) //$NON-NLS-1$
2189
			String fullVirtualName = ArchiveHandlerManager.getFullVirtualName(virtualPath, name);
2190
			if (exists(fullVirtualName)) 
2188
			{
2191
			{
2189
				// wrong method
2192
				return replace(fullVirtualName, file, name);
2190
				return replace(virtualPath + "/" + name, file, name); //$NON-NLS-1$
2191
			}
2193
			}
2192
			else
2194
			else
2193
			{
2195
			{
(-)clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTarHandler.java (-4 / +7 lines)
Lines 13-18 Link Here
13
 * 
13
 * 
14
 * Contributors:
14
 * Contributors:
15
 * {Name} (company) - description of contribution.
15
 * {Name} (company) - description of contribution.
16
 * Xuan Chen        (IBM)        - [194293] [Local][Archives] Saving file second time in an Archive Errors
16
 *******************************************************************************/
17
 *******************************************************************************/
17
18
18
package org.eclipse.rse.services.clientserver.archiveutils;
19
package org.eclipse.rse.services.clientserver.archiveutils;
Lines 1013-1020 Link Here
1013
		if (!file.isDirectory()) {
1014
		if (!file.isDirectory()) {
1014
			
1015
			
1015
			// if it exists, call replace
1016
			// if it exists, call replace
1016
			if (exists(virtualPath + "/" + name)) { //$NON-NLS-1$
1017
			String fullVirtualName = ArchiveHandlerManager.getFullVirtualName(virtualPath, name);
1017
				return replace(virtualPath + "/" + name, file, name); //$NON-NLS-1$
1018
			if (exists(fullVirtualName)) { 
1019
				return replace(fullVirtualName, file, name); 
1018
			}
1020
			}
1019
			else {
1021
			else {
1020
				File[] files = new File[1];
1022
				File[] files = new File[1];
Lines 1099-1106 Link Here
1099
			// if the entry already exists, then we should do a replace
1101
			// if the entry already exists, then we should do a replace
1100
			// TODO (KM): should we simply replace and return?
1102
			// TODO (KM): should we simply replace and return?
1101
			// I think we should check each entry and replace or create for each one
1103
			// I think we should check each entry and replace or create for each one
1102
			if (exists(virtualPath + "/" + names[i])) { //$NON-NLS-1$
1104
			String fullVirtualName = ArchiveHandlerManager.getFullVirtualName(virtualPath, names[i]);
1103
				return replace(virtualPath + "/" + names[i], files[i], names[i]); //$NON-NLS-1$
1105
			if (exists(fullVirtualName)) { 
1106
				return replace(fullVirtualName, files[i], names[i]); 
1104
			}
1107
			}
1105
		}
1108
		}
1106
		
1109
		

Return to bug 194293