## -*- mode: R -*-
## loading code which is first sent to R on remote sessions
local({
    curver <- '%s'
    ## MM: ok for Windows?
    ## VS: Should be fine (who is using win remote anyways?)
    .c.dir <- '~/.config/ESSR'
    verfile <- file.path(.c.dir, 'VERSION')
    envfile <- file.path(.c.dir, 'ESSR.rda')
    ver <- if(file.exists(verfile)) scan(verfile, what = "string") else "0.0"
    tryCatch({
        if(ver < curver) {
            url <- paste('http://vitalie.spinu.info/ESSR/ESSR_', curver, '.rda', sep = '')
            if(!file.exists(.c.dir))
                dir.create(.c.dir, recursive = TRUE)
            utils::download.file(url, envfile)
            cat(curver, file = verfile)
        }
        load(envfile)
        attach(ESSR)
        print(TRUE)
    } , error = function(e) print(FALSE))
})