Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 89388 Details for
Bug 188330
Problems Copying files with $ in name
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
A better patch (in line with dstore CopyThread)
bug218173_dollarCopy.diff.txt (text/plain), 5.30 KB, created by
Martin Oberhuber
on 2008-02-11 06:34:28 EST
(
hide
)
Description:
A better patch (in line with dstore CopyThread)
Filename:
MIME Type:
Creator:
Martin Oberhuber
Created:
2008-02-11 06:34:28 EST
Size:
5.30 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.rse.services.local >Index: src/org/eclipse/rse/internal/services/local/files/LocalFileService.java >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java,v >retrieving revision 1.26 >diff -u -r1.26 LocalFileService.java >--- src/org/eclipse/rse/internal/services/local/files/LocalFileService.java 7 Feb 2008 16:10:19 -0000 1.26 >+++ src/org/eclipse/rse/internal/services/local/files/LocalFileService.java 11 Feb 2008 11:00:42 -0000 >@@ -30,6 +30,7 @@ > * Kevin Doyle (IBM) - [208778] [efs][api] RSEFileStore#getOutputStream() does not support EFS#APPEND > * David McKnight (IBM) - [209593] [api] add support for "file permissions" and "owner" properties for unix files > * Radoslav Gerganov (ProSyst) - [218173] [local] non-generic filters don't work >+ * Martin Oberhuber (Wind River) - [188330] Problems Copying files with $ in name > ********************************************************************************/ > > package org.eclipse.rse.internal.services.local.files; >@@ -1233,8 +1234,20 @@ > return movedOk; > } > >- >- >+ /** >+ * Quote a file name such that it is valid in a shell >+ * @param s file name to quote >+ * @return quoted file name >+ */ >+ protected String enQuote(String s) >+ { >+ if(isWindows()) { >+ return '"' + s + '"'; >+ } else { >+ return PathUtility.enQuoteUnix(s); >+ } >+ } >+ > public boolean copy(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException > { > File srcFile = new File(srcParent, srcName); >@@ -1243,8 +1256,6 @@ > String command = null; > boolean folderCopy = srcFile.isDirectory(); > String src = srcFile.getAbsolutePath(); >- >- > String target = tgtFile.getAbsolutePath(); > > boolean sourceIsVirtual = ArchiveHandlerManager.isVirtual(src); >@@ -1259,24 +1270,10 @@ > return copyToArchive(srcFile, new File(tgtParent), tgtName, monitor, SystemEncodingUtil.ENCODING_UTF_8, SystemEncodingUtil.ENCODING_UTF_8, false); > } > >- > // handle special characters in source and target strings >- StringBuffer srcBuf = new StringBuffer(src); >- StringBuffer tgtBuf = new StringBuffer(target); >- handleSpecialChars(srcBuf); >- handleSpecialChars(tgtBuf); >- >- src = "\"" + srcBuf.toString() + "\""; //$NON-NLS-1$ //$NON-NLS-2$ >- target = "\"" + tgtBuf.toString() + "\""; //$NON-NLS-1$ //$NON-NLS-2$ >- /* >- // handle imbedded blanks of from or to name... >- if (src.indexOf(' ') >= 0) >- src = "\"" + src + "\""; >- if (target.indexOf(' ') >= 0) >- target = "\"" + target + "\""; >- */ >- boolean isWindows = System.getProperty("os.name").toLowerCase().startsWith("win"); //$NON-NLS-1$ //$NON-NLS-2$ >- if (isWindows) >+ src = enQuote(src); >+ target = enQuote(target); >+ if (isWindows()) > { > if (folderCopy) > { >@@ -1284,16 +1281,13 @@ > } > else > { >- //command = _osCmdShell + "copy " + src + " " + target; //$NON-NLS-1$ //$NON-NLS-2$ > // create target first so that not prompted >- File targetFile = new File(tgtBuf.toString()); >- if (!targetFile.exists()) >+ if (!tgtFile.exists()) > { > // create file so as to avoid ambiguity > try > { >- targetFile.createNewFile(); >- >+ tgtFile.createNewFile(); > } > catch (Exception e) > { >@@ -1305,7 +1299,6 @@ > } > else > { >- > if (folderCopy) > { > command = "cp -Rp " + src + " " + target; //$NON-NLS-1$ //$NON-NLS-2$ >@@ -1320,7 +1313,7 @@ > { > Process p = null; > Runtime runtime = Runtime.getRuntime(); >- if (isWindows) >+ if (isWindows()) > { > String theShell = "cmd /C "; //$NON-NLS-1$ > p = runtime.exec(theShell + command); >@@ -1348,39 +1341,6 @@ > return (rc == 0); > } > >- protected void handleSpecialChars(StringBuffer buf) >- { >- for (int i = 0; i < buf.length(); i++) >- { >- char c = buf.charAt(i); >- >- boolean isSpecialChar = isSpecialChar(c); >- >- if (isSpecialChar) >- { >- buf.insert(i, "\\"); //$NON-NLS-1$ >- i++; >- } >- } >- } >- >- /** >- * Checks whether the given character is a special character in the shell. A special character is >- * '$', '`', '"' and '\'. >- * @param c the character to check. >- * @return <code>true</code> if the character is a special character, <code>false</code> otherwise. >- */ >- protected boolean isSpecialChar(char c) { >- >- if ((c == '$') || (c == '`') || (c == '"') || (!isWindows() && (c == '\\')) ) { >- >- return true; >- } >- else { >- return false; >- } >- } >- > /** > * Copy a file or folder to a new target parent folder, but if > * copying from an archive, extract the file in the encoding specified >@@ -1391,7 +1351,7 @@ > * @param sourceEncoding encoding of source file > * @param targetEncoding desired encoding of target file > * @param isText currently unused >- * @return true iff the copy succeeded >+ * @return true if the copy succeeded > */ > public boolean copyFromArchive(File sourceFolderOrFile, File targetFolder, String newName, IProgressMonitor monitor, String sourceEncoding, String targetEncoding, boolean isText) throws SystemMessageException > {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 188330
:
89357
| 89388