| Index: sdk/lib/io/file_system_entity.dart
|
| diff --git a/sdk/lib/io/file_system_entity.dart b/sdk/lib/io/file_system_entity.dart
|
| index a00cb03229638eba8ab8c6330e0ec29cb9ee6692..8d86fe8f5d0f06b47fa57023ae309b32ffe06e37 100644
|
| --- a/sdk/lib/io/file_system_entity.dart
|
| +++ b/sdk/lib/io/file_system_entity.dart
|
| @@ -420,7 +420,7 @@ abstract class FileSystemEntity {
|
|
|
| static _throwIfError(Object result, String msg, [String path]) {
|
| if (result is OSError) {
|
| - throw new FileException(msg, result, path);
|
| + throw new FileException(msg, path, result);
|
| } else if (result is ArgumentError) {
|
| throw result;
|
| }
|
| @@ -535,97 +535,8 @@ class FileSystemMoveEvent extends FileSystemEvent {
|
| }
|
|
|
|
|
| -class _FileSystemWatcher extends NativeFieldWrapperClass1 {
|
| - final String _path;
|
| - final int _events;
|
| - final bool _recursive;
|
| +abstract class _FileSystemWatcher {
|
| + external factory _FileSystemWatcher(String path, int events, bool recursive);
|
|
|
| - StreamController _controller;
|
| - StreamSubscription _subscription;
|
| -
|
| - _FileSystemWatcher(this._path, this._events, this._recursive) {
|
| - _controller = new StreamController(onListen: _listen, onCancel: _cancel);
|
| - }
|
| -
|
| - void _listen() {
|
| - int socketId;
|
| - try {
|
| - socketId = _watchPath(_path, _events, identical(true, _recursive));
|
| - } catch (e) {
|
| - throw new FileException(
|
| - "Failed to watch path",
|
| - _path,
|
| - e);
|
| - }
|
| - var socket = new _RawSocket(new _NativeSocket.watch(socketId));
|
| - _subscription = socket.expand((event) {
|
| - var events = [];
|
| - var pair = {};
|
| - if (event == RawSocketEvent.READ) {
|
| - String getPath(event) {
|
| - var path = _path;
|
| - if (event[2] != null) {
|
| - path += Platform.pathSeparator;
|
| - path += event[2];
|
| - }
|
| - return path;
|
| - }
|
| - while (socket.available() > 0) {
|
| - for (var event in _readEvents()) {
|
| - if (event == null) continue;
|
| - var path = getPath(event);
|
| - if ((event[0] & FileSystemEvent.CREATE) != 0) {
|
| - events.add(new FileSystemCreateEvent._(path));
|
| - }
|
| - if ((event[0] & FileSystemEvent.MODIFY) != 0) {
|
| - events.add(new FileSystemModifyEvent._(path, true));
|
| - }
|
| - if ((event[0] & FileSystemEvent._MODIFY_ATTRIBUTES) != 0) {
|
| - events.add(new FileSystemModifyEvent._(path, false));
|
| - }
|
| - if ((event[0] & FileSystemEvent.MOVE) != 0) {
|
| - int link = event[1];
|
| - if (link > 0) {
|
| - if (pair.containsKey(link)) {
|
| - events.add(
|
| - new FileSystemMoveEvent._(getPath(pair[link]), path));
|
| - pair.remove(link);
|
| - } else {
|
| - pair[link] = event;
|
| - }
|
| - } else {
|
| - events.add(new FileSystemMoveEvent._(path, null));
|
| - }
|
| - }
|
| - if ((event[0] & FileSystemEvent.DELETE) != 0) {
|
| - events.add(new FileSystemDeleteEvent._(path));
|
| - }
|
| - }
|
| - }
|
| - for (var event in pair.values) {
|
| - events.add(new FileSystemMoveEvent._(getPath(event), null));
|
| - }
|
| - } else if (event == RawSocketEvent.CLOSED) {
|
| - } else if (event == RawSocketEvent.READ_CLOSED) {
|
| - } else {
|
| - assert(false);
|
| - }
|
| - return events;
|
| - })
|
| - .where((event) => (event.type & _events) != 0)
|
| - .listen(_controller.add, onDone: _cancel);
|
| - }
|
| -
|
| - void _cancel() {
|
| - _unwatchPath();
|
| - if (_subscription != null) {
|
| - _subscription.cancel();
|
| - }
|
| - }
|
| -
|
| - Stream<FileSystemEvent> get stream => _controller.stream;
|
| -
|
| - external int _watchPath(String path, int events, bool recursive);
|
| - external void _unwatchPath();
|
| - external List _readEvents();
|
| + Stream<FileSystemEvent> get stream;
|
| }
|
|
|