The R Project SVN R

Rev

Rev 5458 | Rev 6098 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5458 Rev 5731
Line 221... Line 221...
221
 
221
 
222
static void GetFullDLLPath(SEXP call, char *buf, char *path)
222
static void GetFullDLLPath(SEXP call, char *buf, char *path)
223
{
223
{
224
    if ((path[0] != '/') && (path[0] != '\\') && (path[1] != ':')) {
224
    if ((path[0] != '/') && (path[0] != '\\') && (path[1] != ':')) {
225
	if (!getcwd(buf, MAX_PATH))
225
	if (!getcwd(buf, MAX_PATH))
226
	    errorcall(call, "can't get working directory!\n");
226
	    errorcall(call, "can't get working directory!");
227
	strcat(buf, "\\");
227
	strcat(buf, "\\");
228
	strcat(buf, path);
228
	strcat(buf, path);
229
    } else
229
    } else
230
	strcpy(buf, path);
230
	strcpy(buf, path);
231
}
231
}
Line 237... Line 237...
237
{
237
{
238
    char  buf[MAX_PATH];
238
    char  buf[MAX_PATH];
239
 
239
 
240
    checkArity(op, args);
240
    checkArity(op, args);
241
    if (!isString(CAR(args)) || length(CAR(args)) != 1)
241
    if (!isString(CAR(args)) || length(CAR(args)) != 1)
242
	errorcall(call, "character argument expected\n");
242
	errorcall(call, "character argument expected");
243
    GetFullDLLPath(call, buf, CHAR(STRING(CAR(args))[0]));
243
    GetFullDLLPath(call, buf, CHAR(STRING(CAR(args))[0]));
244
    DeleteDLL(buf);
244
    DeleteDLL(buf);
245
    if (!AddDLL(buf))
245
    if (!AddDLL(buf))
246
	errorcall(call, "unable to load shared library \"%s\":\n  %s\n",
246
	errorcall(call, "unable to load shared library \"%s\":\n  %s",
247
		  buf, DLLerror);
247
		  buf, DLLerror);
248
    return R_NilValue;
248
    return R_NilValue;
249
}
249
}
250
 
250
 
251
SEXP do_dynunload(SEXP call, SEXP op, SEXP args, SEXP env)
251
SEXP do_dynunload(SEXP call, SEXP op, SEXP args, SEXP env)
252
{
252
{
253
    char  buf[MAX_PATH];
253
    char  buf[MAX_PATH];
254
 
254
 
255
    checkArity(op, args);
255
    checkArity(op, args);
256
    if (!isString(CAR(args)) || length(CAR(args)) != 1)
256
    if (!isString(CAR(args)) || length(CAR(args)) != 1)
257
	errorcall(call, "character argument expected\n");
257
	errorcall(call, "character argument expected");
258
    GetFullDLLPath(call, buf, CHAR(STRING(CAR(args))[0]));
258
    GetFullDLLPath(call, buf, CHAR(STRING(CAR(args))[0]));
259
    if (!DeleteDLL(buf))
259
    if (!DeleteDLL(buf))
260
	errorcall(call, "dynamic library \"%s\" was not loaded\n", buf);
260
	errorcall(call, "dynamic library \"%s\" was not loaded", buf);
261
    return R_NilValue;
261
    return R_NilValue;
262
}
262
}