is_rocrate_bag: Check if path points to a valid RO-Crate bag

View source: R/utils-bag.R

is_rocrate_bagR Documentation

Check if path points to a valid RO-Crate bag

Description

Check if path points to a valid RO-Crate bag

Usage

is_rocrate_bag(path, algo = NULL, bagit_version = "1.0")

Arguments

path

String with full path to a compressed file contain an RO-Crate bag, see bag_rocrate for details. Alternatively, a path to a directory containing an RO-Crate bag.

algo

String with algorithm used to generate the RO-Crate bag (default: NULL, which auto detects the algorithm from the ⁠manifest-<algo>.txt⁠ file, inside the bag). See digest for more details on valid algorithms.

bagit_version

String with version of BagIt used to generate the RO-Crate bag (default: "1.0"). See \Sexpr[results=rd]{tools:::Rd_expr_doi("10.17487/RFC8493")} for more details.

Value

Returns a boolean flag to indicate if the given RO-Crate bag is valid.

See Also

Other RO-Crate BagIt archive functions: bag_rocrate(), load_rocrate_bag(), unbag_rocrate()

Examples

# -------- SETUP --------
basic_crate <- rocrateR::rocrate()
# temp file
tmp_dir <- file.path(tempdir(), digest::digest(basename(tempfile())))
tmp <- file.path(tmp_dir, "ro-crate-metadata.json")
dir.create(tmp_dir)

# bag RO-Crate
path_to_roc_bag <- rocrateR::bag_rocrate(basic_crate, path = tmp_dir)

# -------- INPUT: RO-Crate BagIt archive --------
rocrateR::is_rocrate_bag(path_to_roc_bag)

# -------- INPUT: Path --------
rocrateR::unbag_rocrate(path_to_roc_bag) |>
  rocrateR::is_rocrate_bag()

# delete temp directory
unlink(tmp_dir, recursive = TRUE)

rocrateR documentation built on April 9, 2026, 1:06 a.m.