### Eclipse Workspace Patch 1.0 #P org.eclipse.rse.services Index: clientserver/org/eclipse/rse/services/clientserver/archiveutils/ArchiveHandlerManager.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/archiveutils/ArchiveHandlerManager.java,v retrieving revision 1.5 diff -u -r1.5 ArchiveHandlerManager.java --- clientserver/org/eclipse/rse/services/clientserver/archiveutils/ArchiveHandlerManager.java 5 Jun 2007 10:37:08 -0000 1.5 +++ clientserver/org/eclipse/rse/services/clientserver/archiveutils/ArchiveHandlerManager.java 12 Jul 2007 17:54:05 -0000 @@ -13,6 +13,7 @@ * * Contributors: * {Name} (company) - description of contribution. + * Xuan Chen (IBM) - [194293] [Local][Archives] Saving file second time in an Archive Errors *******************************************************************************/ package org.eclipse.rse.services.clientserver.archiveutils; @@ -367,8 +368,23 @@ String newPath = fullVirtualName; if (j != -1) { - realPart = fullVirtualName.substring(0, j) + VIRTUAL_SEPARATOR; - newPath = fullVirtualName.substring(j + VIRTUAL_SEPARATOR.length()); + try + { + realPart = fullVirtualName.substring(0, j) + VIRTUAL_SEPARATOR; + if (j + VIRTUAL_SEPARATOR.length() < fullVirtualName.length()) + { + newPath = fullVirtualName.substring(j + VIRTUAL_SEPARATOR.length()); + } + else + { + //This is the special case where fullVirtualName ends with VIRTUAL_SEPARATOR + newPath = ""; //$NON-NLS-1$ + } + } + catch (Exception e) + { + e.printStackTrace(); + } } // use only forward slash separator newPath = newPath.replace('\\', '/'); Index: clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemZipHandler.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemZipHandler.java,v retrieving revision 1.7 diff -u -r1.7 SystemZipHandler.java --- clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemZipHandler.java 5 Jul 2007 08:11:40 -0000 1.7 +++ clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemZipHandler.java 12 Jul 2007 17:54:05 -0000 @@ -14,6 +14,7 @@ * Contributors: * {Name} (company) - description of contribution. * Xuan Chen (IBM) - [192741] [Archives] Move a folder from within an Archive doesn't work if > 1 level deep + * Xuan Chen (IBM) - [194293] [Local][Archives] Saving file second time in an Archive Errors *******************************************************************************/ package org.eclipse.rse.services.clientserver.archiveutils; @@ -907,10 +908,11 @@ for (int i = 0; i < numFiles; i++) { if (!files[i].exists() || !files[i].canRead()) return false; - if (exists(virtualPath + "/" + names[i])) //$NON-NLS-1$ + String fullVirtualName = getFullVirtualName(virtualPath, names[i]); + if (exists(fullVirtualName)) { // sorry, wrong method buddy - return replace(virtualPath + "/" + names[i], files[i], names[i]); //$NON-NLS-1$ + return replace(fullVirtualName, files[i], names[i]); } } File outputTempFile; @@ -2184,10 +2186,10 @@ virtualPath = ArchiveHandlerManager.cleanUpVirtualPath(virtualPath); if (!file.isDirectory()) { - if (exists(virtualPath + "/" + name)) //$NON-NLS-1$ + String fullVirtualName = getFullVirtualName(virtualPath, name); + if (exists(fullVirtualName)) { - // wrong method - return replace(virtualPath + "/" + name, file, name); //$NON-NLS-1$ + return replace(fullVirtualName, file, name); } else { @@ -2237,4 +2239,24 @@ return add(sources, virtualPath, newNames, sourceEncodings, targetEncodings, isTexts); } } + + /** + * Construct the full virtual name of a virtual file from its virtual path and name. + * @param virtualPath the virtual path of this virtual file + * @param name the name of this virtual file + * @return the full virtual name of this virtual file + */ + private static String getFullVirtualName(String virtualPath, String name) + { + String fullVirtualName = null; + if (virtualPath == null || virtualPath.length() == 0) + { + fullVirtualName = name; + } + else + { + fullVirtualName = virtualPath + "/" + name; //$NON-NLS-1$ + } + return fullVirtualName; + } } Index: clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTarHandler.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTarHandler.java,v retrieving revision 1.4 diff -u -r1.4 SystemTarHandler.java --- clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTarHandler.java 5 Jun 2007 10:37:08 -0000 1.4 +++ clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTarHandler.java 12 Jul 2007 17:54:05 -0000 @@ -13,6 +13,7 @@ * * Contributors: * {Name} (company) - description of contribution. + * Xuan Chen (IBM) - [194293] [Local][Archives] Saving file second time in an Archive Errors *******************************************************************************/ package org.eclipse.rse.services.clientserver.archiveutils; @@ -1013,8 +1014,9 @@ if (!file.isDirectory()) { // if it exists, call replace - if (exists(virtualPath + "/" + name)) { //$NON-NLS-1$ - return replace(virtualPath + "/" + name, file, name); //$NON-NLS-1$ + String fullVirtualName = getFullVirtualName(virtualPath, name); + if (exists(fullVirtualName)) { + return replace(fullVirtualName, file, name); } else { File[] files = new File[1]; @@ -1099,8 +1101,9 @@ // if the entry already exists, then we should do a replace // TODO (KM): should we simply replace and return? // I think we should check each entry and replace or create for each one - if (exists(virtualPath + "/" + names[i])) { //$NON-NLS-1$ - return replace(virtualPath + "/" + names[i], files[i], names[i]); //$NON-NLS-1$ + String fullVirtualName = getFullVirtualName(virtualPath, names[i]); + if (exists(fullVirtualName)) { + return replace(fullVirtualName, files[i], names[i]); } } @@ -2253,4 +2256,24 @@ // TODO Auto-generated method stub return false; } + + /** + * Construct the full virtual name of a virtual file from its virtual path and name. + * @param virtualPath the virtual path of this virtual file + * @param name the name of this virtual file + * @return the full virtual name of this virtual file + */ + private static String getFullVirtualName(String virtualPath, String name) + { + String fullVirtualName = null; + if (virtualPath == null || virtualPath.length() == 0) + { + fullVirtualName = name; + } + else + { + fullVirtualName = virtualPath + "/" + name; //$NON-NLS-1$ + } + return fullVirtualName; + } }