mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
further changes for Bug 291815 - fix test failure on UNIX/Linux
This commit is contained in:
parent
0dd48245de
commit
98977cbde4
2 changed files with 14 additions and 2 deletions
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue