File: acquireFile.R

package info (click to toggle)
r-bioc-alabaster.base 1.6.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 1,652 kB
  • sloc: cpp: 11,377; sh: 29; makefile: 2
file content (22 lines) | stat: -rw-r--r-- 774 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#' @export
#' @rdname acquireFile
setMethod("acquireFile", "character", function(project, path) file.path(project, path))

#' @export
#' @rdname acquireFile
#' @importFrom jsonlite fromJSON
setMethod("acquireMetadata", "character", function(project, path) {
    full.path <- file.path(project, path)

    # Obtaining the path to the actual metadata file. This may not exist for
    # metadata-only documents, which point to themselves (and should end be
    # JSON files and end with '.json')
    meta.path <- paste0(full.path, ".json")
    if (file.exists(meta.path)) {
        full.path <- meta.path
    } else if (!grepl("\\.json$", full.path)) {
        stop("'", path, "' has no accompanying JSON metadata file")
    }

    fromJSON(full.path, simplifyVector=FALSE)
})