Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion R/watch.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ Watcher <- R6Class(
if (!is.null(callback) && !is.function(callback)) {
callback <- rlang::as_function(callback)
}
latency <- as.double(latency)
private$watch <- .Call(watcher_create, private$path, callback, latency)
}
invisible(self)
Expand Down
11 changes: 6 additions & 5 deletions src/watcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,20 @@ static void session_finalizer(SEXP xptr) {
SEXP watcher_create(SEXP path, SEXP callback, SEXP latency) {

const char *watch_path = Rf_translateChar(STRING_ELT(path, 0));
const double lat = REAL(latency)[0];
const double lat = Rf_asReal(latency);

FSW_HANDLE handle = fsw_init_session(system_default_monitor_type);
if (handle == NULL)
watcher_error(handle, "Watcher failed to allocate memory.");

if (fsw_add_path(handle, watch_path) != FSW_OK)
watcher_error(handle, "Watcher path invalid.");
/* no need to test return value of fsw_add_path() as it only errors if the
* path is a null pointer, and Rf_translateChar() cannot return one
*/
fsw_add_path(handle, watch_path);

if (XLENGTH(path) > 1) {
for (R_xlen_t i = 1; i < XLENGTH(path); i++) {
if (fsw_add_path(handle, Rf_translateChar(STRING_ELT(path, i))) != FSW_OK)
watcher_error(handle, "Watcher path invalid.");
fsw_add_path(handle, Rf_translateChar(STRING_ELT(path, i)));
}
}

Expand Down
Loading