Skip to contents

verifies that, were the stamp recalculated, it would match the one previously set with stamp_set() of stamp_save().

Usage

stamp_confirm(
  x = NULL,
  st_dir = NULL,
  st_name = NULL,
  st_file = NULL,
  stamp = NULL,
  hash = NULL,
  st_ext = getOption("stamp.default.ext"),
  verbose = getOption("stamp.verbose"),
  set_hash = FALSE,
  replace = FALSE,
  ...
)

Arguments

x

R object to write to disk as per limitations of file format.

st_dir

character: parent directory where the stamp file if saved.

st_name

character: name of stamp (see details).

st_file

character: path of stamp file to compare with.

stamp

previously calculated stamp with stamp_get.

hash

previously calculated stamp with stamp_get(x). This will be compared against the stamps in file. You can't provide x along with hash. Of them must be NULL.

st_ext

character: format of stamp file to save. Default is value in option "stamp.default.ext"

verbose

logical: whether to display additional information. This could be changed in option "stamp.verbose". Default is TRUE

set_hash

Logical or character. The hash is the intermediate stamp estimated to confirm that data has not changed. If FALSE, the default, hash won't be set as part of the .stamp env. If TRUE, a random name would be assigned to the hash and it will be saved in .stamp env. If character, it would be use as the stamp name in .stamp env.

replace

logical: replace hash in .stamp env in case it already exists. Default is FALSE.

...

Arguments passed on to stamp_get

algo

character: default is value in option "stamp.digest.algo". This argument is the algorithms to be used; currently available choices are md5, which is also the default, sha1, crc32, sha256, sha512, xxhash32, xxhash64, murmur32, spookyhash and blake3

serialize

A logical variable indicating whether the object should be serialized using serialize (in ASCII form). Setting this to FALSE allows to compare the digest output of given character strings to known control output. It also allows the use of raw vectors such as the output of non-ASCII serialization.

file

A logical variable indicating whether the object is a file name or a file name if object is not specified.

length

Number of characters to process. By default, when length is set to Inf, the whole string or file is processed.

skip

Number of input bytes to skip before calculating the digest. Negative values are invalid and currently treated as zero. Special value "auto" will cause serialization header to be skipped if serialize is set to TRUE (the serialization header contains the R version number thus skipping it allows the comparison of hashes across platforms and some R versions).

ascii

This flag is passed to the serialize function if serialize is set to TRUE, determining whether the hash is computed on the ASCII or binary representation.

raw

A logical variable with a default value of FALSE, implying digest returns digest output as ASCII hex values. Set to TRUE to return digest output in raw (binary) form. Note that this option is supported by most but not all of the implemented hashing algorithms

seed

an integer to seed the random number generator. This is only used in the xxhash32, xxhash64 and murmur32 functions and can be used to generate additional hashes for the same input if desired.

errormode

A character value denoting a choice for the behaviour in the case of error: ‘stop’ aborts (and is the default value), ‘warn’ emits a warning and returns NULL and ‘silent’ suppresses the error and returns an empty string.

Value

Logical value. FALSE if the objects do not match and TRUE if they do.

Details

st_name is the name of the stamp and it could be used in two different ways. First, if st_dir is NULL, it is assumed that the user refers to st_name as the stamp saved in the .stamp env and not to a stamp saved in a particular drive. If st_dir is not NULL, then st_name is the name of file that contains the stamp. Notice that all stamps that are saved to disk are prefixed with the value in option "stamp.stamp_prefix", which by default is "st_". You don't need to add the prefix, but if you do and it happens to be the same as in "stamp.stamp_prefix", it will be ignored.

See also

Other stamp functions: stamp_get(), stamp_read(), stamp_save(), stamp_set(), stamp_time(), stamp_x_attr()

Examples

if (FALSE) {
  x <- data.frame(a = 1:5, b = "hola")
  st_name <- "stx"
  stamp_set(x, st_name, replace = TRUE)
  # must provide st_dir or st_name
  stamp_confirm(x, st_name = st_name)
}