1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-14 04:25:21 +02:00

[276194] cannot open file with '...' in pathname

This commit is contained in:
David McKnight 2009-05-14 17:17:42 +00:00
parent c985ce92ca
commit f8162e8ff8

View file

@ -13,10 +13,13 @@
* Contributors: * Contributors:
* Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
* David Dykstal (IBM) - [226561] Add API markup to RSE javadocs for extend / implement * David Dykstal (IBM) - [226561] Add API markup to RSE javadocs for extend / implement
* David McKnight (IBM) - [276194] cannot open file with '...' in pathname
********************************************************************************/ ********************************************************************************/
package org.eclipse.rse.core.model; package org.eclipse.rse.core.model;
import java.io.File;
/** /**
* This is a utility class used in the construction of file names. * This is a utility class used in the construction of file names.
* @noextend This class is not intended to be subclassed by clients. * @noextend This class is not intended to be subclassed by clients.
@ -27,6 +30,7 @@ public class SystemEscapeCharHelper {
private char changedChars[]; private char changedChars[];
private int escapeStringLength; private int escapeStringLength;
private boolean isWindows;
/** /**
* Constructor. * Constructor.
@ -34,6 +38,7 @@ public class SystemEscapeCharHelper {
*/ */
public SystemEscapeCharHelper (char[] chars) public SystemEscapeCharHelper (char[] chars)
{ {
isWindows = System.getProperty("os.name").toLowerCase().startsWith("win"); //$NON-NLS-1$//$NON-NLS-2$
changedChars = new char[chars.length+1]; changedChars = new char[chars.length+1];
for (int i = 0; i < chars.length; i++) for (int i = 0; i < chars.length; i++)
@ -53,11 +58,13 @@ public class SystemEscapeCharHelper {
String fileName = name; String fileName = name;
int i = 0; int i = 0;
while (i < fileName.length()) while (i < fileName.length())
{ {
char currentChar = fileName.charAt(i);
for (int j = 0; j < changedChars.length; j++) for (int j = 0; j < changedChars.length; j++)
{ {
if (fileName.charAt(i) == changedChars[j]) if (currentChar == changedChars[j])
{ {
if ((fileName.length()-1) >= i) if ((fileName.length()-1) >= i)
{ {
@ -69,6 +76,14 @@ public class SystemEscapeCharHelper {
} }
i = i + escapeStringLength-1; i = i + escapeStringLength-1;
} }
else if (currentChar == '.' && isWindows){ // special case for bug 276194
if (fileName.length() > i + 1){
char nextChar = fileName.charAt(i + 1);
if (nextChar == '.' || nextChar == File.separatorChar){
fileName = fileName.substring(0, i) + escapeString(currentChar) + fileName.substring(i+1);
}
}
}
} }
i++; i++;
} }