File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed
Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,6 @@ Watcher <- R6Class(
6767 if (! is.null(callback ) && ! is.function(callback )) {
6868 callback <- rlang :: as_function(callback )
6969 }
70- latency <- as.double(latency )
7170 private $ watch <- .Call(watcher_create , private $ path , callback , latency )
7271 }
7372 invisible (self )
Original file line number Diff line number Diff line change @@ -109,19 +109,20 @@ static void session_finalizer(SEXP xptr) {
109109SEXP watcher_create (SEXP path , SEXP callback , SEXP latency ) {
110110
111111 const char * watch_path = Rf_translateChar (STRING_ELT (path , 0 ));
112- const double lat = REAL (latency )[ 0 ] ;
112+ const double lat = Rf_asReal (latency );
113113
114114 FSW_HANDLE handle = fsw_init_session (system_default_monitor_type );
115115 if (handle == NULL )
116116 watcher_error (handle , "Watcher failed to allocate memory." );
117117
118- if (fsw_add_path (handle , watch_path ) != FSW_OK )
119- watcher_error (handle , "Watcher path invalid." );
118+ /* no need to test return value of fsw_add_path() as it only errors if the
119+ * path is a null pointer, and Rf_translateChar() cannot return one
120+ */
121+ fsw_add_path (handle , watch_path );
120122
121123 if (XLENGTH (path ) > 1 ) {
122124 for (R_xlen_t i = 1 ; i < XLENGTH (path ); i ++ ) {
123- if (fsw_add_path (handle , Rf_translateChar (STRING_ELT (path , i ))) != FSW_OK )
124- watcher_error (handle , "Watcher path invalid." );
125+ fsw_add_path (handle , Rf_translateChar (STRING_ELT (path , i )));
125126 }
126127 }
127128
You can’t perform that action at this time.
0 commit comments