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 / +18 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('\\', '/');
(-)clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemZipHandler.java (-5 / +27 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 = 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 = 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
			{
Lines 2237-2240 Link Here
2237
			return add(sources, virtualPath, newNames, sourceEncodings, targetEncodings, isTexts);
2239
			return add(sources, virtualPath, newNames, sourceEncodings, targetEncodings, isTexts);
2238
		}
2240
		}
2239
	}
2241
	}
2242
	
2243
	/**
2244
	 * Construct the full virtual name of a virtual file from its virtual path and name.
2245
	 * @param virtualPath the virtual path of this virtual file
2246
	 * @param name the name of this virtual file
2247
	 * @return the full virtual name of this virtual file
2248
	 */
2249
	private static String getFullVirtualName(String virtualPath, String name)
2250
	{
2251
		String fullVirtualName = null;
2252
		if (virtualPath == null || virtualPath.length() == 0)
2253
		{
2254
			fullVirtualName = name;
2255
		}
2256
		else
2257
		{
2258
			fullVirtualName = virtualPath + "/" + name;  //$NON-NLS-1$
2259
		}
2260
		return fullVirtualName;
2261
	}
2240
}
2262
}
(-)clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTarHandler.java (-4 / +27 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 = 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 = 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
		
Lines 2253-2256 Link Here
2253
		// TODO Auto-generated method stub
2256
		// TODO Auto-generated method stub
2254
		return false;
2257
		return false;
2255
	}
2258
	}
2259
	
2260
	/**
2261
	 * Construct the full virtual name of a virtual file from its virtual path and name.
2262
	 * @param virtualPath the virtual path of this virtual file
2263
	 * @param name the name of this virtual file
2264
	 * @return the full virtual name of this virtual file
2265
	 */
2266
	private static String getFullVirtualName(String virtualPath, String name)
2267
	{
2268
		String fullVirtualName = null;
2269
		if (virtualPath == null || virtualPath.length() == 0)
2270
		{
2271
			fullVirtualName = name;
2272
		}
2273
		else
2274
		{
2275
			fullVirtualName = virtualPath + "/" + name;  //$NON-NLS-1$
2276
		}
2277
		return fullVirtualName;
2278
	}
2256
}
2279
}

Return to bug 194293