From 31ba993cba4b686f7af5e6afd44ac6114195a677 Mon Sep 17 00:00:00 2001 From: Xuan Chen Date: Fri, 15 Feb 2008 05:39:26 +0000 Subject: [PATCH] [218491] ArchiveHandlerManager#cleanUpVirtualPath is messing up the file separators (with updated fix) --- .../archiveutils/ArchiveHandlerManager.java | 16 +++++++++++++-- .../archiveutils/SystemTarHandler.java | 20 +++++++++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/archiveutils/ArchiveHandlerManager.java b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/archiveutils/ArchiveHandlerManager.java index 7fdb825409c..551c40683aa 100644 --- a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/archiveutils/ArchiveHandlerManager.java +++ b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/archiveutils/ArchiveHandlerManager.java @@ -16,7 +16,7 @@ * Xuan Chen (IBM) - [194293] [Local][Archives] Saving file second time in an Archive Errors * Xuan Chen (IBM) - [202949] [archives] copy a folder from one connection to an archive file in a different connection does not work * Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread - * Xuan Chen (IBM) - [218491] ArchiveHandlerManager#cleanUpVirtualPath is messing up the file separators + * Xuan Chen (IBM) - [218491] ArchiveHandlerManager#cleanUpVirtualPath is messing up the file separators (with updated fix) *******************************************************************************/ package org.eclipse.rse.services.clientserver.archiveutils; @@ -367,7 +367,19 @@ public class ArchiveHandlerManager public static String cleanUpVirtualPath(String fullVirtualName) { int j = fullVirtualName.indexOf(VIRTUAL_CANONICAL_SEPARATOR); - if (j == -1) return fullVirtualName; + if (j == -1) + { + //fullVirtualName does not contains VIRTUAL_CANONICAL_SEPARATOR + //fullVirtualName could be the virtual path only, instead of the full path. + //So even fullVirtualName does not contains VIRTUAL_CANONICAL_SEPARATOR, we may still + //need to process it. + //But virtual path should neither start with "\", nor contains + //":". So for those two cases, we could just return the fullVirtualName + if (fullVirtualName.indexOf(":") != -1 || fullVirtualName.trim().startsWith("\\")) + { + return fullVirtualName; + } + } String realPart = ""; //$NON-NLS-1$ String newPath = fullVirtualName; if (j != -1) diff --git a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTarHandler.java b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTarHandler.java index a7641ef10c3..58a47651021 100644 --- a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTarHandler.java +++ b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTarHandler.java @@ -22,6 +22,7 @@ * Xuan Chen (IBM) - [211653] Copy virtual directory with nested directory of tar file did not work * Xuan Chen (IBM) - [214251] [archive] "Last Modified Time" changed for all virtual files/folders if rename/paste/delete of one virtual file. * Xuan Chen (IBM) - [191370] [dstore] Supertransfer zip not deleted when cancelling copy + * Xuan Chen (IBM) - [218491] ArchiveHandlerManager#cleanUpVirtualPath is messing up the file separators *******************************************************************************/ package org.eclipse.rse.services.clientserver.archiveutils; @@ -1355,10 +1356,21 @@ public class SystemTarHandler implements ISystemArchiveHandler { if (children[i].isDirectory) { // include a '/' at the end, since it is a directory - TarEntry nextEntry = tarFile.getEntry(children[i].fullName + "/"); //$NON-NLS-1$ + TarEntry nextEntry = null; + if (!children[i].fullName.endsWith("/")) //$NON-NLS-1$ + { + nextEntry = tarFile.getEntry(children[i].fullName + "/"); //$NON-NLS-1$ + } + else + { + nextEntry = tarFile.getEntry(children[i].fullName); + } // put the entry - outStream.putNextEntry(nextEntry); + if (null != nextEntry) + { + outStream.putNextEntry(nextEntry); + } // close the entry outStream.closeEntry(); @@ -2150,6 +2162,10 @@ public class SystemTarHandler implements ISystemArchiveHandler { */ public boolean createFolder(String fullVirtualName, ISystemOperationMonitor archiveOperationMonitor) { fullVirtualName = ArchiveHandlerManager.cleanUpVirtualPath(fullVirtualName); + if (fullVirtualName.startsWith("folder1")) + { + System.out.println("fullVirtualName is: " + fullVirtualName); + } fullVirtualName = fullVirtualName + "/"; //$NON-NLS-1$ boolean returnCode = createVirtualObject(fullVirtualName, archiveOperationMonitor); setArchiveOperationMonitorStatusDone(archiveOperationMonitor);