diff --git a/sdk/lib/_internal/compiler/implementation/dart2js.dart b/sdk/lib/_internal/compiler/implementation/dart2js.dart index f51abf55c92..bc9c6becb27 100644 --- a/sdk/lib/_internal/compiler/implementation/dart2js.dart +++ b/sdk/lib/_internal/compiler/implementation/dart2js.dart @@ -376,7 +376,7 @@ Future compile(List argv) { } RandomAccessFile output = - new File(uriPathToNative(uri.path)).openSync(mode: FileMode.WRITE); + new File(uri.toFilePath()).openSync(mode: FileMode.WRITE); int charactersWritten = 0; writeStringSync(String data) { @@ -445,7 +445,7 @@ void writeString(Uri uri, String text) { if (uri.scheme != 'file') { fail('Error: Unhandled scheme ${uri.scheme}.'); } - var file = new File(uriPathToNative(uri.path)).openSync(mode: FileMode.WRITE); + var file = new File(uri.toFilePath()).openSync(mode: FileMode.WRITE); file.writeStringSync(text); file.closeSync(); } diff --git a/sdk/lib/_internal/compiler/implementation/elements/modelx.dart b/sdk/lib/_internal/compiler/implementation/elements/modelx.dart index 78ad54785fa..775841d0362 100644 --- a/sdk/lib/_internal/compiler/implementation/elements/modelx.dart +++ b/sdk/lib/_internal/compiler/implementation/elements/modelx.dart @@ -971,6 +971,9 @@ class LibraryElementX extends ElementX implements LibraryElement { * Returns the library name (as defined by the library tag) or for script * (which have no library tag) the script file name. The latter case is used * to private 'library name' for scripts to use for instance in dartdoc. + * + * Note: the returned filename will still be escaped ("a%20b.dart" instead of + * "a b.dart"). */ String getLibraryOrScriptName() { if (libraryTag != null) { diff --git a/sdk/lib/_internal/compiler/implementation/source_file_provider.dart b/sdk/lib/_internal/compiler/implementation/source_file_provider.dart index 4640ff50517..ab11a776404 100644 --- a/sdk/lib/_internal/compiler/implementation/source_file_provider.dart +++ b/sdk/lib/_internal/compiler/implementation/source_file_provider.dart @@ -42,7 +42,7 @@ abstract class SourceFileProvider { } List source; try { - source = readAll(uriPathToNative(resourceUri.path)); + source = readAll(resourceUri.toFilePath()); } on FileSystemException catch (ex) { return new Future.error( "Error reading '${relativize(cwd, resourceUri, isWindows)}' " diff --git a/tests/compiler/dart2js/async_compiler_input_provider_test.dart b/tests/compiler/dart2js/async_compiler_input_provider_test.dart index 6a4502218a2..7f370c31267 100644 --- a/tests/compiler/dart2js/async_compiler_input_provider_test.dart +++ b/tests/compiler/dart2js/async_compiler_input_provider_test.dart @@ -31,7 +31,7 @@ Future provideInput(Uri uri) { var source = SOURCES[uri.path]; if (source == null) { // Not one of our source files, so assume it's a built-in. - source = new File(uriPathToNative(uri.path)).readAsStringSync(); + source = new File(uri.toFilePath()).readAsStringSync(); } // Deliver the input asynchronously. diff --git a/tests/compiler/dart2js/path with spaces/file with spaces.dart b/tests/compiler/dart2js/path with spaces/file with spaces.dart new file mode 100644 index 00000000000..b0cc20402f8 --- /dev/null +++ b/tests/compiler/dart2js/path with spaces/file with spaces.dart @@ -0,0 +1,9 @@ +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'library space/lib with spaces.dart'; + +main() { + if (foo() != 499) throw "bad value"; +} diff --git a/tests/compiler/dart2js/path with spaces/library space/lib with spaces.dart b/tests/compiler/dart2js/path with spaces/library space/lib with spaces.dart new file mode 100644 index 00000000000..16da6e3295b --- /dev/null +++ b/tests/compiler/dart2js/path with spaces/library space/lib with spaces.dart @@ -0,0 +1,9 @@ +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +library spaces; + +part "part space/part space.dart"; + +foo() => bar(); diff --git a/tests/compiler/dart2js/path with spaces/library space/part space/part space.dart b/tests/compiler/dart2js/path with spaces/library space/part space/part space.dart new file mode 100644 index 00000000000..58aff0fb6e8 --- /dev/null +++ b/tests/compiler/dart2js/path with spaces/library space/part space/part space.dart @@ -0,0 +1,7 @@ +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +part of spaces; + +bar() => 499; diff --git a/tests/compiler/dart2js/space_test.dart b/tests/compiler/dart2js/space_test.dart new file mode 100644 index 00000000000..6eeafcd94a2 --- /dev/null +++ b/tests/compiler/dart2js/space_test.dart @@ -0,0 +1,18 @@ +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:io'; +import '../../../sdk/lib/_internal/compiler/implementation/dart2js.dart' + as dart2js; + +main() { + Uri currentDirectory = Uri.base; + Uri script = currentDirectory.resolveUri(Platform.script); + Uri libraryRoot = script.resolve('../../../sdk/'); + Directory.current = script.resolve("path with spaces").toFilePath(); + + return dart2js.main(["--library-root=${libraryRoot.toFilePath()}", + "--analyze-only", + "file with spaces.dart"]); +}