| 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 "bin/file_system_watcher.h" | 5 #include "bin/file_system_watcher.h" |
| 6 | 6 |
| 7 #include "bin/builtin.h" | 7 #include "bin/builtin.h" |
| 8 #include "bin/dartutils.h" | 8 #include "bin/dartutils.h" |
| 9 | 9 |
| 10 #include "include/dart_api.h" | 10 #include "include/dart_api.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 Dart_SetReturnValue(args, Dart_NewBoolean(FileSystemWatcher::IsSupported())); | 28 Dart_SetReturnValue(args, Dart_NewBoolean(FileSystemWatcher::IsSupported())); |
| 29 } | 29 } |
| 30 | 30 |
| 31 void FUNCTION_NAME(FileSystemWatcher_WatchPath)(Dart_NativeArguments args) { | 31 void FUNCTION_NAME(FileSystemWatcher_WatchPath)(Dart_NativeArguments args) { |
| 32 Dart_Handle watcher = Dart_GetNativeArgument(args, 0); | 32 Dart_Handle watcher = Dart_GetNativeArgument(args, 0); |
| 33 const char* path = DartUtils::GetStringValue(Dart_GetNativeArgument(args, 1)); | 33 const char* path = DartUtils::GetStringValue(Dart_GetNativeArgument(args, 1)); |
| 34 int events = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2)); | 34 int events = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2)); |
| 35 bool recursive = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 3)); | 35 bool recursive = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 3)); |
| 36 intptr_t id = FileSystemWatcher::WatchPath(path, events, recursive); | 36 intptr_t id = FileSystemWatcher::WatchPath(path, events, recursive); |
| 37 if (id == -1) { | 37 if (id == -1) { |
| 38 Dart_PropagateError(DartUtils::NewDartOSError()); | 38 Dart_ThrowException(DartUtils::NewDartOSError()); |
| 39 } else { | 39 } else { |
| 40 SetWatcherIdNativeField(watcher, id); | 40 SetWatcherIdNativeField(watcher, id); |
| 41 } | 41 } |
| 42 intptr_t socket_id = FileSystemWatcher::GetSocketId(id); | 42 intptr_t socket_id = FileSystemWatcher::GetSocketId(id); |
| 43 Dart_SetReturnValue(args, Dart_NewInteger(socket_id)); | 43 Dart_SetReturnValue(args, Dart_NewInteger(socket_id)); |
| 44 } | 44 } |
| 45 | 45 |
| 46 | 46 |
| 47 void FUNCTION_NAME(FileSystemWatcher_UnwatchPath)(Dart_NativeArguments args) { | 47 void FUNCTION_NAME(FileSystemWatcher_UnwatchPath)(Dart_NativeArguments args) { |
| 48 Dart_Handle watcher = Dart_GetNativeArgument(args, 0); | 48 Dart_Handle watcher = Dart_GetNativeArgument(args, 0); |
| 49 intptr_t id; | 49 intptr_t id; |
| 50 GetWatcherIdNativeField(watcher, &id); | 50 GetWatcherIdNativeField(watcher, &id); |
| 51 FileSystemWatcher::UnwatchPath(id); | 51 FileSystemWatcher::UnwatchPath(id); |
| 52 } | 52 } |
| 53 | 53 |
| 54 | 54 |
| 55 void FUNCTION_NAME(FileSystemWatcher_ReadEvents)(Dart_NativeArguments args) { | 55 void FUNCTION_NAME(FileSystemWatcher_ReadEvents)(Dart_NativeArguments args) { |
| 56 Dart_Handle watcher = Dart_GetNativeArgument(args, 0); | 56 Dart_Handle watcher = Dart_GetNativeArgument(args, 0); |
| 57 intptr_t id; | 57 intptr_t id; |
| 58 GetWatcherIdNativeField(watcher, &id); | 58 GetWatcherIdNativeField(watcher, &id); |
| 59 Dart_Handle handle = FileSystemWatcher::ReadEvents(id); | 59 Dart_Handle handle = FileSystemWatcher::ReadEvents(id); |
| 60 ThrowIfError(handle); | 60 ThrowIfError(handle); |
| 61 Dart_SetReturnValue(args, handle); | 61 Dart_SetReturnValue(args, handle); |
| 62 } | 62 } |
| 63 | 63 |
| 64 } // namespace bin | 64 } // namespace bin |
| 65 } // namespace dart | 65 } // namespace dart |
| OLD | NEW |