OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 http.io; | |
6 | |
7 @MirrorsUsed(targets: const ['dart.io.HttpClient', 'dart.io.HttpException', | 5 @MirrorsUsed(targets: const ['dart.io.HttpClient', 'dart.io.HttpException', |
8 'dart.io.File']) | 6 'dart.io.File']) |
9 import 'dart:mirrors'; | 7 import 'dart:mirrors'; |
10 | 8 |
11 /// Whether `dart:io` is supported on this platform. | 9 /// Whether `dart:io` is supported on this platform. |
12 bool get supported => _library != null; | 10 bool get supported => _library != null; |
13 | 11 |
14 /// The `dart:io` library mirror, or `null` if it couldn't be loaded. | 12 /// The `dart:io` library mirror, or `null` if it couldn't be loaded. |
15 final _library = _getLibrary(); | 13 final _library = _getLibrary(); |
16 | 14 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 46 |
49 /// Tries to load `dart:io` and returns `null` if it fails. | 47 /// Tries to load `dart:io` and returns `null` if it fails. |
50 LibraryMirror _getLibrary() { | 48 LibraryMirror _getLibrary() { |
51 try { | 49 try { |
52 return currentMirrorSystem().findLibrary(const Symbol('dart.io')); | 50 return currentMirrorSystem().findLibrary(const Symbol('dart.io')); |
53 } catch (_) { | 51 } catch (_) { |
54 // TODO(nweiz): narrow the catch clause when issue 18532 is fixed. | 52 // TODO(nweiz): narrow the catch clause when issue 18532 is fixed. |
55 return null; | 53 return null; |
56 } | 54 } |
57 } | 55 } |
OLD | NEW |