| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library dart2js.cmdline; | 5 library dart2js.cmdline; |
| 6 | 6 |
| 7 import 'dart:async' | 7 import 'dart:async' |
| 8 show Future, EventSink; | 8 show Future, EventSink; |
| 9 import 'dart:io' | 9 import 'dart:io' |
| 10 show exit, File, FileMode, Platform, RandomAccessFile; | 10 show exit, File, FileMode, Platform, RandomAccessFile; |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 } | 369 } |
| 370 } else { | 370 } else { |
| 371 uri = out.resolve('$name.$extension'); | 371 uri = out.resolve('$name.$extension'); |
| 372 } | 372 } |
| 373 | 373 |
| 374 if (uri.scheme != 'file') { | 374 if (uri.scheme != 'file') { |
| 375 fail('Error: Unhandled scheme ${uri.scheme} in $uri.'); | 375 fail('Error: Unhandled scheme ${uri.scheme} in $uri.'); |
| 376 } | 376 } |
| 377 | 377 |
| 378 RandomAccessFile output = | 378 RandomAccessFile output = |
| 379 new File(uriPathToNative(uri.path)).openSync(mode: FileMode.WRITE); | 379 new File(uri.toFilePath()).openSync(mode: FileMode.WRITE); |
| 380 int charactersWritten = 0; | 380 int charactersWritten = 0; |
| 381 | 381 |
| 382 writeStringSync(String data) { | 382 writeStringSync(String data) { |
| 383 // Write the data in chunks of 8kb, otherwise we risk running OOM | 383 // Write the data in chunks of 8kb, otherwise we risk running OOM |
| 384 int chunkSize = 8*1024; | 384 int chunkSize = 8*1024; |
| 385 | 385 |
| 386 int offset = 0; | 386 int offset = 0; |
| 387 while (offset < data.length) { | 387 while (offset < data.length) { |
| 388 output.writeStringSync( | 388 output.writeStringSync( |
| 389 data.substring(offset, math.min(offset + chunkSize, data.length))); | 389 data.substring(offset, math.min(offset + chunkSize, data.length))); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 class AbortLeg { | 438 class AbortLeg { |
| 439 final message; | 439 final message; |
| 440 AbortLeg(this.message); | 440 AbortLeg(this.message); |
| 441 toString() => 'Aborted due to --throw-on-error: $message'; | 441 toString() => 'Aborted due to --throw-on-error: $message'; |
| 442 } | 442 } |
| 443 | 443 |
| 444 void writeString(Uri uri, String text) { | 444 void writeString(Uri uri, String text) { |
| 445 if (uri.scheme != 'file') { | 445 if (uri.scheme != 'file') { |
| 446 fail('Error: Unhandled scheme ${uri.scheme}.'); | 446 fail('Error: Unhandled scheme ${uri.scheme}.'); |
| 447 } | 447 } |
| 448 var file = new File(uriPathToNative(uri.path)).openSync(mode: FileMode.WRITE); | 448 var file = new File(uri.toFilePath()).openSync(mode: FileMode.WRITE); |
| 449 file.writeStringSync(text); | 449 file.writeStringSync(text); |
| 450 file.closeSync(); | 450 file.closeSync(); |
| 451 } | 451 } |
| 452 | 452 |
| 453 void fail(String message) { | 453 void fail(String message) { |
| 454 if (diagnosticHandler != null) { | 454 if (diagnosticHandler != null) { |
| 455 diagnosticHandler.diagnosticHandler( | 455 diagnosticHandler.diagnosticHandler( |
| 456 null, -1, -1, message, api.Diagnostic.ERROR); | 456 null, -1, -1, message, api.Diagnostic.ERROR); |
| 457 } else { | 457 } else { |
| 458 print(message); | 458 print(message); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 } | 622 } |
| 623 } | 623 } |
| 624 | 624 |
| 625 try { | 625 try { |
| 626 return compilerMain(arguments).catchError(onError); | 626 return compilerMain(arguments).catchError(onError); |
| 627 } catch (exception, trace) { | 627 } catch (exception, trace) { |
| 628 onError(exception, trace); | 628 onError(exception, trace); |
| 629 return new Future.value(); | 629 return new Future.value(); |
| 630 } | 630 } |
| 631 } | 631 } |
| OLD | NEW |