| Index: runtime/bin/file_system_watcher.cc
|
| diff --git a/runtime/bin/file_system_watcher.cc b/runtime/bin/file_system_watcher.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..701fb038f6f7f4ce7f5d730d0adf41a1a22f8e5a
|
| --- /dev/null
|
| +++ b/runtime/bin/file_system_watcher.cc
|
| @@ -0,0 +1,66 @@
|
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
| +// for details. All rights reserved. Use of this source code is governed by a
|
| +// BSD-style license that can be found in the LICENSE file.
|
| +
|
| +#include "bin/file_system_watcher.h"
|
| +
|
| +#include "bin/builtin.h"
|
| +#include "bin/dartutils.h"
|
| +
|
| +#include "include/dart_api.h"
|
| +
|
| +namespace dart {
|
| +namespace bin {
|
| +
|
| +void FUNCTION_NAME(FileSystemWatcher_WatchPath)(Dart_NativeArguments args) {
|
| + const char* path = DartUtils::GetStringValue(Dart_GetNativeArgument(args, 1));
|
| + int events = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2));
|
| + bool recursive = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 3));
|
| + intptr_t path_id = FileSystemWatcher::WatchPath(path, events, recursive);
|
| + if (path_id == -1) {
|
| + Dart_SetReturnValue(args, DartUtils::NewDartOSError());
|
| + } else {
|
| + Dart_SetReturnValue(args, Dart_NewInteger(path_id));
|
| + }
|
| +}
|
| +
|
| +
|
| +void FUNCTION_NAME(FileSystemWatcher_UnwatchPath)(Dart_NativeArguments args) {
|
| + intptr_t id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 1));
|
| + FileSystemWatcher::UnwatchPath(id);
|
| +}
|
| +
|
| +
|
| +void FUNCTION_NAME(FileSystemWatcher_GetSocketId)(Dart_NativeArguments args) {
|
| + intptr_t id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 1));
|
| + intptr_t socket_id = FileSystemWatcher::GetSocketId(id);
|
| + Dart_SetReturnValue(args, Dart_NewInteger(socket_id));
|
| +}
|
| +
|
| +void FUNCTION_NAME(FileSystemWatcher_ReadEvents)(Dart_NativeArguments args) {
|
| + intptr_t id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 1));
|
| + FileSystemWatcher::Event* events = NULL;
|
| + intptr_t count = FileSystemWatcher::ReadEvents(id, &events);
|
| + if (count < 0) {
|
| + Dart_ThrowException(DartUtils::NewDartOSError());
|
| + }
|
| + Dart_Handle result = Dart_NewList(count);
|
| + for (intptr_t i = 0; i < count; i++) {
|
| + Dart_Handle event = Dart_NewList(4);
|
| + Dart_ListSetAt(event, 0, Dart_NewInteger(events[i].event));
|
| + Dart_ListSetAt(event, 1, Dart_NewInteger(events[i].path_id));
|
| + if (events[i].filename != NULL) {
|
| + Dart_ListSetAt(event, 2, Dart_NewStringFromCString(events[i].filename));
|
| + free(const_cast<char*>(events[i].filename));
|
| + } else {
|
| + Dart_ListSetAt(event, 2, Dart_Null());
|
| + }
|
| + Dart_ListSetAt(event, 3, Dart_NewInteger(events[i].link));
|
| + Dart_ListSetAt(result, i, event);
|
| + }
|
| + delete[] events;
|
| + Dart_SetReturnValue(args, result);
|
| +}
|
| +
|
| +} // namespace bin
|
| +} // namespace dart
|
|
|