| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 patch class _File { | 5 patch class _File { |
| 6 /* patch */ static _exists(String path) native "File_Exists"; | 6 /* patch */ static _exists(String path) native "File_Exists"; |
| 7 /* patch */ static _create(String path) native "File_Create"; | 7 /* patch */ static _create(String path) native "File_Create"; |
| 8 /* patch */ static _createLink(String path, String target) | 8 /* patch */ static _createLink(String path, String target) |
| 9 native "File_CreateLink"; | 9 native "File_CreateLink"; |
| 10 /* patch */ static _linkTarget(String path) native "File_LinkTarget"; | 10 /* patch */ static _linkTarget(String path) native "File_LinkTarget"; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 } | 63 } |
| 64 _controller = new StreamController.broadcast(onListen: _listen, | 64 _controller = new StreamController.broadcast(onListen: _listen, |
| 65 onCancel: _cancel); | 65 onCancel: _cancel); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void _listen() { | 68 void _listen() { |
| 69 int socketId; | 69 int socketId; |
| 70 try { | 70 try { |
| 71 socketId = _watchPath(_path, _events, identical(true, _recursive)); | 71 socketId = _watchPath(_path, _events, identical(true, _recursive)); |
| 72 } catch (e) { | 72 } catch (e) { |
| 73 throw new FileSystemException( | 73 _controller.addError(new FileSystemException( |
| 74 "Failed to watch path", | 74 "Failed to watch path", _path, e)); |
| 75 _path, | 75 _controller.close(); |
| 76 e); | 76 return; |
| 77 } | 77 } |
| 78 var socket = new _RawSocket(new _NativeSocket.watch(socketId)); | 78 var socket = new _RawSocket(new _NativeSocket.watch(socketId)); |
| 79 _subscription = socket.expand((event) { | 79 _subscription = socket.expand((event) { |
| 80 bool stop = false; | 80 bool stop = false; |
| 81 var events = []; | 81 var events = []; |
| 82 var pair = {}; | 82 var pair = {}; |
| 83 if (event == RawSocketEvent.READ) { | 83 if (event == RawSocketEvent.READ) { |
| 84 String getPath(event) { | 84 String getPath(event) { |
| 85 var path = _path; | 85 var path = _path; |
| 86 if (event[2] != null) { | 86 if (event[2] != null) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 158 |
| 159 int _watchPath(String path, int events, bool recursive) | 159 int _watchPath(String path, int events, bool recursive) |
| 160 native "FileSystemWatcher_WatchPath"; | 160 native "FileSystemWatcher_WatchPath"; |
| 161 void _unwatchPath() native "FileSystemWatcher_UnwatchPath"; | 161 void _unwatchPath() native "FileSystemWatcher_UnwatchPath"; |
| 162 List _readEvents() native "FileSystemWatcher_ReadEvents"; | 162 List _readEvents() native "FileSystemWatcher_ReadEvents"; |
| 163 } | 163 } |
| 164 | 164 |
| 165 Uint8List _makeUint8ListView(Uint8List source, int offsetInBytes, int length) { | 165 Uint8List _makeUint8ListView(Uint8List source, int offsetInBytes, int length) { |
| 166 return new Uint8List.view(source.buffer, offsetInBytes, length); | 166 return new Uint8List.view(source.buffer, offsetInBytes, length); |
| 167 } | 167 } |
| OLD | NEW |