| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 implements _FileSystemWatcher { | 50 implements _FileSystemWatcher { |
| 51 final String _path; | 51 final String _path; |
| 52 final int _events; | 52 final int _events; |
| 53 final bool _recursive; | 53 final bool _recursive; |
| 54 | 54 |
| 55 StreamController _controller; | 55 StreamController _controller; |
| 56 StreamSubscription _subscription; | 56 StreamSubscription _subscription; |
| 57 | 57 |
| 58 _FileSystemWatcherImpl(this._path, this._events, this._recursive) { | 58 _FileSystemWatcherImpl(this._path, this._events, this._recursive) { |
| 59 if (!isSupported) { | 59 if (!isSupported) { |
| 60 throw new FileException( | 60 throw new FileSystemException( |
| 61 "File system watching is not supported on this system", | 61 "File system watching is not supported on this system", |
| 62 _path); | 62 _path); |
| 63 } | 63 } |
| 64 _controller = new StreamController(onListen: _listen, onCancel: _cancel); | 64 _controller = new StreamController(onListen: _listen, onCancel: _cancel); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void _listen() { | 67 void _listen() { |
| 68 int socketId; | 68 int socketId; |
| 69 try { | 69 try { |
| 70 socketId = _watchPath(_path, _events, identical(true, _recursive)); | 70 socketId = _watchPath(_path, _events, identical(true, _recursive)); |
| 71 } catch (e) { | 71 } catch (e) { |
| 72 throw new FileException( | 72 throw new FileSystemException( |
| 73 "Failed to watch path", | 73 "Failed to watch path", |
| 74 _path, | 74 _path, |
| 75 e); | 75 e); |
| 76 } | 76 } |
| 77 var socket = new _RawSocket(new _NativeSocket.watch(socketId)); | 77 var socket = new _RawSocket(new _NativeSocket.watch(socketId)); |
| 78 _subscription = socket.expand((event) { | 78 _subscription = socket.expand((event) { |
| 79 bool stop = false; | 79 bool stop = false; |
| 80 var events = []; | 80 var events = []; |
| 81 var pair = {}; | 81 var pair = {}; |
| 82 if (event == RawSocketEvent.READ) { | 82 if (event == RawSocketEvent.READ) { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 157 |
| 158 int _watchPath(String path, int events, bool recursive) | 158 int _watchPath(String path, int events, bool recursive) |
| 159 native "FileSystemWatcher_WatchPath"; | 159 native "FileSystemWatcher_WatchPath"; |
| 160 void _unwatchPath() native "FileSystemWatcher_UnwatchPath"; | 160 void _unwatchPath() native "FileSystemWatcher_UnwatchPath"; |
| 161 List _readEvents() native "FileSystemWatcher_ReadEvents"; | 161 List _readEvents() native "FileSystemWatcher_ReadEvents"; |
| 162 } | 162 } |
| 163 | 163 |
| 164 Uint8List _makeUint8ListView(Uint8List source, int offsetInBytes, int length) { | 164 Uint8List _makeUint8ListView(Uint8List source, int offsetInBytes, int length) { |
| 165 return new Uint8List.view(source.buffer, offsetInBytes, length); | 165 return new Uint8List.view(source.buffer, offsetInBytes, length); |
| 166 } | 166 } |
| OLD | NEW |