R/magma_uninstall.R

Defines functions magma_uninstall

Documented in magma_uninstall

#' Uninstall MAGMA
#' 
#' Uninstall one or all versions of MAGMA.
#' 
#' @param version Which version of MAGMA to uninstall. If \code{NULL}, 
#' will uninstall all versions found.
#' @param verbose Print messages.
#' 
#' @return Path(s) to MAGMA installation folder(s) that were deleted.
#' @export
#' @examples 
#' MAGMA.Celltyping::magma_uninstall()
magma_uninstall <- function(version = NULL,
                            verbose = TRUE){
    magma_x = magma_executable(version = version,
                               return_all = is.null(version),
                               verbose = verbose)
    if(length(magma_x)>0){
        messager("Removing",length(magma_x),"installed versions of MAGMA.",
                 v=verbose)
        out1 <- unlink(dirname(magma_x), 
                       recursive = TRUE, 
                       force = TRUE)
        out2 <- file.remove(paste0(dirname(magma_x),".zip"))
        logs <- list.files("magma*",dirname(dirname(magma_x)))
        if(length(logs)>0) try({out3 <- file.remove(logs)})
    } else {
        messager("There are no MAGMA installations to remove.",
                 v=verbose)
    }
    return(dirname(magma_x))
}
NathanSkene/MAGMA_Celltyping documentation built on Aug. 21, 2023, 8:55 a.m.