### 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 9 Jul 2007 01:53:57 -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 9 Jul 2007 01:53:59 -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,19 @@ 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 = null; + if (virtualPath == null || virtualPath.length() == 0) + { + fullVirtualName = names[i]; + } + else + { + fullVirtualName = virtualPath + "/" + names[i]; //$NON-NLS-1$ + } + 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; @@ -2182,12 +2192,21 @@ { if (!_exists) return false; virtualPath = ArchiveHandlerManager.cleanUpVirtualPath(virtualPath); + if (!file.isDirectory()) { - if (exists(virtualPath + "/" + name)) //$NON-NLS-1$ + String fullVirtualName = null; + if (virtualPath == null || virtualPath.length() == 0) { - // wrong method - return replace(virtualPath + "/" + name, file, name); //$NON-NLS-1$ + fullVirtualName = name; + } + else + { + fullVirtualName = virtualPath + "/" + name; //$NON-NLS-1$ + } + if (exists(fullVirtualName)) + { + return replace(fullVirtualName, file, name); } else { 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 9 Jul 2007 01:53:58 -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,17 @@ 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 = null; + if (virtualPath == null || virtualPath.length() == 0) + { + fullVirtualName = name; + } + else + { + fullVirtualName = virtualPath + "/" + name; //$NON-NLS-1$ + } + if (exists(fullVirtualName)) { + return replace(fullVirtualName, file, name); } else { File[] files = new File[1]; @@ -1099,8 +1109,17 @@ // 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 = null; + if (virtualPath == null || virtualPath.length() == 0) + { + fullVirtualName = names[i]; + } + else + { + fullVirtualName = virtualPath + "/" + names[i]; //$NON-NLS-1$ + } + if (exists(fullVirtualName)) { + return replace(fullVirtualName, files[i], names[i]); } }