R/oc.R

Defines functions owncloud

Documented in owncloud

#' owncloud
#'
#' An owncloud client adapted for R. 
#'
#' @param dir       oc directory to synchronize, relative to basedir.
#'                  dir can be missing only if the root directory was synchronized already. 
#' @param basedir   local directory. default to ~/ownCloud/
#' @param exclude   files and/or file types to exclude. default to  c("*.sublime-workspace", ".Rproj.user")
#'
#' @return owncloudcmd verbose output returned invisibly. 
#' 
#' @export
#' @importFrom rprojroot  has_file_pattern  find_root
#' 
owncloud <- function(dir, basedir = '~/ownCloud/', exclude = c("*.sublime-workspace", ".Rproj.user")  ) {


    cnf = getocini()

    glue('mkdir -p {basedir}/{dir}') %>% 
        system
    
    # make exclude file
    exf = paste0(system('echo $HOME', intern=TRUE), '/.config/owncloudcmd/.owncloud_exclude.lst') 
    writeLines(exclude, exf)
    
    # run
    tf = tempfile()
    cmd = glue("owncloudcmd -h --nonshib --user {cnf['user']} --password {shQuote(cnf['pwd'])} --exclude {exf} \\
        {basedir}/{dir} https://{cnf['url']}/remote.php/nonshib-webdav/{dir} > {tf} 2>&1 ")
    
    system(cmd)
    
    invisible(readLines(tf))


}
mpio-be/owncloud documentation built on Jan. 22, 2020, 12:53 a.m.