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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 } else { | 136 } else { |
137 assert(false); | 137 assert(false); |
138 } | 138 } |
139 if (stop) socket.close(); | 139 if (stop) socket.close(); |
140 return events; | 140 return events; |
141 }) | 141 }) |
142 .listen(_controller.add, onDone: _cancel); | 142 .listen(_controller.add, onDone: _cancel); |
143 } | 143 } |
144 | 144 |
145 void _cancel() { | 145 void _cancel() { |
146 _unwatchPath(); | |
147 if (_subscription != null) { | 146 if (_subscription != null) { |
| 147 _unwatchPath(); |
148 _subscription.cancel(); | 148 _subscription.cancel(); |
| 149 _subscription = null; |
149 } | 150 } |
150 _controller.close(); | 151 _controller.close(); |
151 } | 152 } |
152 | 153 |
153 Stream<FileSystemEvent> get stream => _controller.stream; | 154 Stream<FileSystemEvent> get stream => _controller.stream; |
154 | 155 |
155 static bool get isSupported native "FileSystemWatcher_IsSupported"; | 156 static bool get isSupported native "FileSystemWatcher_IsSupported"; |
156 | 157 |
157 int _watchPath(String path, int events, bool recursive) | 158 int _watchPath(String path, int events, bool recursive) |
158 native "FileSystemWatcher_WatchPath"; | 159 native "FileSystemWatcher_WatchPath"; |
159 void _unwatchPath() native "FileSystemWatcher_UnwatchPath"; | 160 void _unwatchPath() native "FileSystemWatcher_UnwatchPath"; |
160 List _readEvents() native "FileSystemWatcher_ReadEvents"; | 161 List _readEvents() native "FileSystemWatcher_ReadEvents"; |
161 } | 162 } |
162 | 163 |
163 Uint8List _makeUint8ListView(Uint8List source, int offsetInBytes, int length) { | 164 Uint8List _makeUint8ListView(Uint8List source, int offsetInBytes, int length) { |
164 return new Uint8List.view(source.buffer, offsetInBytes, length); | 165 return new Uint8List.view(source.buffer, offsetInBytes, length); |
165 } | 166 } |
OLD | NEW |