OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 #include "platform/globals.h" | 5 #include "platform/globals.h" |
6 #if defined(TARGET_OS_MACOS) | 6 #if defined(TARGET_OS_MACOS) |
7 | 7 |
8 #include "bin/file_system_watcher.h" | 8 #include "bin/file_system_watcher.h" |
9 | 9 |
10 #include <errno.h> // NOLINT | 10 #include <errno.h> // NOLINT |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 private: | 194 private: |
195 static void Callback(ConstFSEventStreamRef ref, | 195 static void Callback(ConstFSEventStreamRef ref, |
196 void* client, | 196 void* client, |
197 size_t num_events, | 197 size_t num_events, |
198 void* event_paths, | 198 void* event_paths, |
199 const FSEventStreamEventFlags event_flags[], | 199 const FSEventStreamEventFlags event_flags[], |
200 const FSEventStreamEventId event_ids[]) { | 200 const FSEventStreamEventId event_ids[]) { |
201 Node* node = reinterpret_cast<Node*>(client); | 201 Node* node = reinterpret_cast<Node*>(client); |
202 for (size_t i = 0; i < num_events; i++) { | 202 for (size_t i = 0; i < num_events; i++) { |
203 char *path = reinterpret_cast<char**>(event_paths)[i]; | 203 char *path = reinterpret_cast<char**>(event_paths)[i]; |
204 path += node->base_path_length() + 1; | 204 path += node->base_path_length(); |
| 205 // If path is longer the base, skip next character ('/'). |
| 206 if (path[0] != '\0') path += 1; |
205 if (!node->recursive() && strstr(path, "/") != NULL) continue; | 207 if (!node->recursive() && strstr(path, "/") != NULL) continue; |
206 FSEvent event; | 208 FSEvent event; |
207 event.data.flags = event_flags[i]; | 209 event.data.flags = event_flags[i]; |
208 memmove(event.data.path, path, strlen(path) + 1); | 210 memmove(event.data.path, path, strlen(path) + 1); |
209 write(node->write_fd(), event.bytes, sizeof(event)); | 211 write(node->write_fd(), event.bytes, sizeof(event)); |
210 } | 212 } |
211 } | 213 } |
212 | 214 |
213 CFRunLoopRef run_loop_; | 215 CFRunLoopRef run_loop_; |
214 int users_; | 216 int users_; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 } | 287 } |
286 return events; | 288 return events; |
287 } | 289 } |
288 | 290 |
289 } // namespace bin | 291 } // namespace bin |
290 } // namespace dart | 292 } // namespace dart |
291 | 293 |
292 #endif // defined(TARGET_OS_MACOS) | 294 #endif // defined(TARGET_OS_MACOS) |
293 | 295 |
294 | 296 |
OLD | NEW |