Add some warnings in README
[pkgdev.git] / R / unload.R
... / ...
CommitLineData
1# Core function to unload a package (UNsource R files and unload C libraries)
2# @param path Location or name of the (non-standard) package to be unloaded
3.pkgdev.unload = function(path) {
4
5 # Get package name from path
6 pathTokens = strsplit(path, c(.Platform$file.sep))[[1]]
7 pkgName = pathTokens[length(pathTokens)]
8
9 # This file tells if the package is currently loaded
10 pkdev_path = file.path(Sys.getenv("R_HOME_USER"), "pkgdev")
11 pkgLoadFile = file.path(pkdev_path,"pkgs",pkgName,"loaded")
12
13 # Unload shared library (if any)
14 if (file.exists(pkgLoadFile)) {
15 sharedLib = file.path(pkdev_path,"pkgs",pkgName,paste(pkgName,.Platform$dynlib.ext,sep=''))
16 dyn.unload(sharedLib)
17 unlink(pkgLoadFile)
18 }
19}