| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 if (event[2] != null) { | 86 if (event[2] != null) { |
| 87 path += Platform.pathSeparator; | 87 path += Platform.pathSeparator; |
| 88 path += event[2]; | 88 path += event[2]; |
| 89 } | 89 } |
| 90 return path; | 90 return path; |
| 91 } | 91 } |
| 92 void add(event) { | 92 void add(event) { |
| 93 if ((event.type & _events) == 0) return; | 93 if ((event.type & _events) == 0) return; |
| 94 events.add(event); | 94 events.add(event); |
| 95 } | 95 } |
| 96 void rewriteMove(event) { |
| 97 if (event[3]) { |
| 98 add(new FileSystemCreateEvent._(getPath(event))); |
| 99 } else { |
| 100 add(new FileSystemDeleteEvent._(getPath(event))); |
| 101 } |
| 102 } |
| 96 while (socket.available() > 0) { | 103 while (socket.available() > 0) { |
| 97 for (var event in _readEvents()) { | 104 for (var event in _readEvents()) { |
| 98 if (event == null) continue; | 105 if (event == null) continue; |
| 99 var path = getPath(event); | 106 var path = getPath(event); |
| 100 if ((event[0] & FileSystemEvent.CREATE) != 0) { | 107 if ((event[0] & FileSystemEvent.CREATE) != 0) { |
| 101 add(new FileSystemCreateEvent._(path)); | 108 add(new FileSystemCreateEvent._(path)); |
| 102 } | 109 } |
| 103 if ((event[0] & FileSystemEvent.MODIFY) != 0) { | 110 if ((event[0] & FileSystemEvent.MODIFY) != 0) { |
| 104 add(new FileSystemModifyEvent._(path, true)); | 111 add(new FileSystemModifyEvent._(path, true)); |
| 105 } | 112 } |
| 106 if ((event[0] & FileSystemEvent._MODIFY_ATTRIBUTES) != 0) { | 113 if ((event[0] & FileSystemEvent._MODIFY_ATTRIBUTES) != 0) { |
| 107 add(new FileSystemModifyEvent._(path, false)); | 114 add(new FileSystemModifyEvent._(path, false)); |
| 108 } | 115 } |
| 109 if ((event[0] & FileSystemEvent.MOVE) != 0) { | 116 if ((event[0] & FileSystemEvent.MOVE) != 0) { |
| 110 int link = event[1]; | 117 int link = event[1]; |
| 111 if (link > 0) { | 118 if (link > 0) { |
| 112 if (pair.containsKey(link)) { | 119 if (pair.containsKey(link)) { |
| 113 events.add( | 120 events.add( |
| 114 new FileSystemMoveEvent._(getPath(pair[link]), path)); | 121 new FileSystemMoveEvent._(getPath(pair[link]), path)); |
| 115 pair.remove(link); | 122 pair.remove(link); |
| 116 } else { | 123 } else { |
| 117 pair[link] = event; | 124 pair[link] = event; |
| 118 } | 125 } |
| 119 } else { | 126 } else { |
| 120 add(new FileSystemMoveEvent._(path, null)); | 127 rewriteMove(event); |
| 121 } | 128 } |
| 122 } | 129 } |
| 123 if ((event[0] & FileSystemEvent.DELETE) != 0) { | 130 if ((event[0] & FileSystemEvent.DELETE) != 0) { |
| 124 add(new FileSystemDeleteEvent._(path)); | 131 add(new FileSystemDeleteEvent._(path)); |
| 125 } | 132 } |
| 126 if ((event[0] & FileSystemEvent._DELETE_SELF) != 0) { | 133 if ((event[0] & FileSystemEvent._DELETE_SELF) != 0) { |
| 127 add(new FileSystemDeleteEvent._(path)); | 134 add(new FileSystemDeleteEvent._(path)); |
| 128 stop = true; | 135 stop = true; |
| 129 } | 136 } |
| 130 } | 137 } |
| 131 } | 138 } |
| 132 for (var event in pair.values) { | 139 for (var event in pair.values) { |
| 133 events.add(new FileSystemMoveEvent._(getPath(event), null)); | 140 rewriteMove(event); |
| 134 } | 141 } |
| 135 } else if (event == RawSocketEvent.CLOSED) { | 142 } else if (event == RawSocketEvent.CLOSED) { |
| 136 } else if (event == RawSocketEvent.READ_CLOSED) { | 143 } else if (event == RawSocketEvent.READ_CLOSED) { |
| 137 } else { | 144 } else { |
| 138 assert(false); | 145 assert(false); |
| 139 } | 146 } |
| 140 if (stop) socket.close(); | 147 if (stop) socket.close(); |
| 141 return events; | 148 return events; |
| 142 }) | 149 }) |
| 143 .listen(_controller.add, onDone: _cancel); | 150 .listen(_controller.add, onDone: _cancel); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 158 | 165 |
| 159 int _watchPath(String path, int events, bool recursive) | 166 int _watchPath(String path, int events, bool recursive) |
| 160 native "FileSystemWatcher_WatchPath"; | 167 native "FileSystemWatcher_WatchPath"; |
| 161 void _unwatchPath() native "FileSystemWatcher_UnwatchPath"; | 168 void _unwatchPath() native "FileSystemWatcher_UnwatchPath"; |
| 162 List _readEvents() native "FileSystemWatcher_ReadEvents"; | 169 List _readEvents() native "FileSystemWatcher_ReadEvents"; |
| 163 } | 170 } |
| 164 | 171 |
| 165 Uint8List _makeUint8ListView(Uint8List source, int offsetInBytes, int length) { | 172 Uint8List _makeUint8ListView(Uint8List source, int offsetInBytes, int length) { |
| 166 return new Uint8List.view(source.buffer, offsetInBytes, length); | 173 return new Uint8List.view(source.buffer, offsetInBytes, length); |
| 167 } | 174 } |
| OLD | NEW |