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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 static void Callback(ConstFSEventStreamRef ref, | 174 static void Callback(ConstFSEventStreamRef ref, |
175 void* client, | 175 void* client, |
176 size_t num_events, | 176 size_t num_events, |
177 void* event_paths, | 177 void* event_paths, |
178 const FSEventStreamEventFlags event_flags[], | 178 const FSEventStreamEventFlags event_flags[], |
179 const FSEventStreamEventId event_ids[]) { | 179 const FSEventStreamEventId event_ids[]) { |
180 Node* node = reinterpret_cast<Node*>(client); | 180 Node* node = reinterpret_cast<Node*>(client); |
181 for (size_t i = 0; i < num_events; i++) { | 181 for (size_t i = 0; i < num_events; i++) { |
182 char *path = reinterpret_cast<char**>(event_paths)[i]; | 182 char *path = reinterpret_cast<char**>(event_paths)[i]; |
183 FSEvent event; | 183 FSEvent event; |
184 event.data.exists = File::Exists(path); | 184 event.data.exists = File::GetType(path, false) != File::kDoesNotExist; |
185 path += node->base_path_length(); | 185 path += node->base_path_length(); |
186 // If path is longer the base, skip next character ('/'). | 186 // If path is longer the base, skip next character ('/'). |
187 if (path[0] != '\0') path += 1; | 187 if (path[0] != '\0') path += 1; |
188 if (!node->recursive() && strstr(path, "/") != NULL) continue; | 188 if (!node->recursive() && strstr(path, "/") != NULL) continue; |
189 event.data.flags = event_flags[i]; | 189 event.data.flags = event_flags[i]; |
190 memmove(event.data.path, path, strlen(path) + 1); | 190 memmove(event.data.path, path, strlen(path) + 1); |
191 write(node->write_fd(), event.bytes, sizeof(event)); | 191 write(node->write_fd(), event.bytes, sizeof(event)); |
192 } | 192 } |
193 } | 193 } |
194 | 194 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 } | 291 } |
292 return events; | 292 return events; |
293 } | 293 } |
294 | 294 |
295 } // namespace bin | 295 } // namespace bin |
296 } // namespace dart | 296 } // namespace dart |
297 | 297 |
298 #endif // defined(TARGET_OS_MACOS) | 298 #endif // defined(TARGET_OS_MACOS) |
299 | 299 |
300 | 300 |
OLD | NEW |