1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

further changes for Bug 291815 - fix test failure on UNIX/Linux

This commit is contained in:
Chris Recoskie 2010-05-27 01:40:19 +00:00
parent 0dd48245de
commit 98977cbde4
2 changed files with 14 additions and 2 deletions

View file

@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.core.internal.efsextension.tests;
import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
@ -109,7 +110,15 @@ public class EFSExtensionTests extends TestCase {
URI expected = null;
try {
originalURI = new URI("file", "/c:/foo", null);
expected = new URI("file", "/c:/foo/subdirectory", null);
if(java.io.File.separatorChar == '\\') {
expected = new URI("file", "/c:/foo/subdirectory", null);
}
else {
// if we're not on Windows then backslash is not the path separator, and instead
// is a valid filename character. Using a backslash will result in it being escaped.
expected = new URI("file", "/c:%5Cfoo%5Csubdirectory", null);
}
} catch (URISyntaxException e) {
fail(e.getMessage());
}

View file

@ -75,6 +75,9 @@ public abstract class EFSExtensionProvider {
* null on error.
*
* The default implementation places the path in the path field of the URI, ensuring that there is a leading slash.
* It also determines whether or not to convert backslashes in the provided path based on whether or not the
* local operating system's file separator is a backslash, thus ensuring proper behaviour for URIs corresponding
* to the local filesystem.
*
* @param locationOnSameFilesystem
* @param path An absolute path.
@ -84,7 +87,7 @@ public abstract class EFSExtensionProvider {
URI uri = locationOnSameFilesystem;
Path p = new Path(path);
String pathString = p.toString(); // to convert any backslashes to slashes
String pathString = p.toString(); // to convert any backslashes to slashes if we are on Windows
final int length = pathString.length();
StringBuffer pathBuf = new StringBuffer(length + 1);