@@ -59,7 +59,7 @@ void* watcher_thread(void *args) {
59
59
60
60
SEXP watcher_create (SEXP path , SEXP recursive , SEXP callback ) {
61
61
62
- const char * watch_path = R_ExpandFileName ( CHAR (STRING_ELT (path , 0 ) ));
62
+ const char * watch_path = CHAR (STRING_ELT (path , 0 ));
63
63
const int recurse = LOGICAL (recursive )[0 ];
64
64
if (callback != R_NilValue ) {
65
65
SEXPTYPE typ = TYPEOF (callback );
@@ -93,14 +93,9 @@ SEXP watcher_create(SEXP path, SEXP recursive, SEXP callback) {
93
93
}
94
94
}
95
95
96
- SEXP out , PathSymbol ;
97
- PathSymbol = Rf_install ("path" );
96
+ SEXP out ;
98
97
PROTECT (out = R_MakeExternalPtr (handle , R_NilValue , callback ));
99
98
R_RegisterCFinalizerEx (out , session_finalizer , TRUE);
100
- Rf_setAttrib (out , PathSymbol , Rf_mkString (watch_path ));
101
- Rf_setAttrib (out , Rf_install ("recursive" ), Rf_ScalarLogical (recurse ));
102
- Rf_setAttrib (out , Rf_install ("active" ), Rf_ScalarLogical (0 ));
103
- Rf_classgets (out , Rf_mkString ("watch" ));
104
99
105
100
UNPROTECT (1 );
106
101
return out ;
@@ -109,33 +104,21 @@ SEXP watcher_create(SEXP path, SEXP recursive, SEXP callback) {
109
104
110
105
SEXP watcher_start_monitor (SEXP session ) {
111
106
112
- if (TYPEOF (session ) != EXTPTRSXP )
113
- return Rf_ScalarLogical (0 );
114
-
115
107
FSW_HANDLE handle = (FSW_HANDLE ) R_ExternalPtrAddr (session );
116
108
pthread_t thr ;
117
109
118
110
if (eln2 == NULL && R_ToplevelExec (load_later_safe , NULL )) {
119
111
eln2 = (void (* )(void (* )(void * ), void * , double , int )) R_GetCCallable ("later" , "execLaterNative2" );
120
112
}
121
113
122
- const int started = pthread_create (& thr , NULL , & watcher_thread , handle ) == 0 ;
123
- Rf_setAttrib (session , Rf_install ("active" ), Rf_ScalarLogical (started ));
124
-
125
- return Rf_ScalarLogical (started );
114
+ return Rf_ScalarLogical (pthread_create (& thr , NULL , & watcher_thread , handle ) == 0 );
126
115
127
116
}
128
117
129
118
SEXP watcher_stop_monitor (SEXP session ) {
130
119
131
- if (TYPEOF (session ) != EXTPTRSXP )
132
- return Rf_ScalarLogical (0 );
133
-
134
120
FSW_HANDLE handle = (FSW_HANDLE ) R_ExternalPtrAddr (session );
135
121
136
- const int stopped = fsw_stop_monitor (handle ) == FSW_OK ;
137
- Rf_setAttrib (session , Rf_install ("active" ), Rf_ScalarLogical (!stopped ));
138
-
139
- return Rf_ScalarLogical (stopped );
122
+ return Rf_ScalarLogical (fsw_stop_monitor (handle ) == FSW_OK );
140
123
141
124
}
0 commit comments