mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-15 04:55:22 +02:00
[194293] Xuan's patch for Saving file second time in an Archive Errors
This commit is contained in:
parent
9b746334ea
commit
54645d9950
3 changed files with 72 additions and 11 deletions
|
@ -13,6 +13,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* {Name} (company) - description of contribution.
|
* {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;
|
package org.eclipse.rse.services.clientserver.archiveutils;
|
||||||
|
@ -367,8 +368,23 @@ public class ArchiveHandlerManager
|
||||||
String newPath = fullVirtualName;
|
String newPath = fullVirtualName;
|
||||||
if (j != -1)
|
if (j != -1)
|
||||||
{
|
{
|
||||||
realPart = fullVirtualName.substring(0, j) + VIRTUAL_SEPARATOR;
|
try
|
||||||
newPath = fullVirtualName.substring(j + VIRTUAL_SEPARATOR.length());
|
{
|
||||||
|
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
|
// use only forward slash separator
|
||||||
newPath = newPath.replace('\\', '/');
|
newPath = newPath.replace('\\', '/');
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* {Name} (company) - description of contribution.
|
* {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;
|
package org.eclipse.rse.services.clientserver.archiveutils;
|
||||||
|
@ -1013,8 +1014,9 @@ public class SystemTarHandler implements ISystemArchiveHandler {
|
||||||
if (!file.isDirectory()) {
|
if (!file.isDirectory()) {
|
||||||
|
|
||||||
// if it exists, call replace
|
// if it exists, call replace
|
||||||
if (exists(virtualPath + "/" + name)) { //$NON-NLS-1$
|
String fullVirtualName = getFullVirtualName(virtualPath, name);
|
||||||
return replace(virtualPath + "/" + name, file, name); //$NON-NLS-1$
|
if (exists(fullVirtualName)) {
|
||||||
|
return replace(fullVirtualName, file, name);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
File[] files = new File[1];
|
File[] files = new File[1];
|
||||||
|
@ -1099,8 +1101,9 @@ public class SystemTarHandler implements ISystemArchiveHandler {
|
||||||
// if the entry already exists, then we should do a replace
|
// if the entry already exists, then we should do a replace
|
||||||
// TODO (KM): should we simply replace and return?
|
// TODO (KM): should we simply replace and return?
|
||||||
// I think we should check each entry and replace or create for each one
|
// I think we should check each entry and replace or create for each one
|
||||||
if (exists(virtualPath + "/" + names[i])) { //$NON-NLS-1$
|
String fullVirtualName = getFullVirtualName(virtualPath, names[i]);
|
||||||
return replace(virtualPath + "/" + names[i], files[i], names[i]); //$NON-NLS-1$
|
if (exists(fullVirtualName)) {
|
||||||
|
return replace(fullVirtualName, files[i], names[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2253,4 +2256,24 @@ public class SystemTarHandler implements ISystemArchiveHandler {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* {Name} (company) - description of contribution.
|
* {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) - [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;
|
package org.eclipse.rse.services.clientserver.archiveutils;
|
||||||
|
@ -907,10 +908,11 @@ public class SystemZipHandler implements ISystemArchiveHandler
|
||||||
for (int i = 0; i < numFiles; i++)
|
for (int i = 0; i < numFiles; i++)
|
||||||
{
|
{
|
||||||
if (!files[i].exists() || !files[i].canRead()) return false;
|
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
|
// 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;
|
File outputTempFile;
|
||||||
|
@ -2184,10 +2186,10 @@ public class SystemZipHandler implements ISystemArchiveHandler
|
||||||
virtualPath = ArchiveHandlerManager.cleanUpVirtualPath(virtualPath);
|
virtualPath = ArchiveHandlerManager.cleanUpVirtualPath(virtualPath);
|
||||||
if (!file.isDirectory())
|
if (!file.isDirectory())
|
||||||
{
|
{
|
||||||
if (exists(virtualPath + "/" + name)) //$NON-NLS-1$
|
String fullVirtualName = getFullVirtualName(virtualPath, name);
|
||||||
|
if (exists(fullVirtualName))
|
||||||
{
|
{
|
||||||
// wrong method
|
return replace(fullVirtualName, file, name);
|
||||||
return replace(virtualPath + "/" + name, file, name); //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2237,4 +2239,24 @@ public class SystemZipHandler implements ISystemArchiveHandler
|
||||||
return add(sources, virtualPath, newNames, sourceEncodings, targetEncodings, isTexts);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue