Write file with md5 hash check
Usage
write_file_md5(
x,
path = NULL,
method = mark_write_methods(),
overwrite = NA,
quiet = FALSE,
encoding = "UTF-8",
compression = getOption("mark.compress.method", mark_compress_methods()),
...
)
mark_write_methods()
mark_compress_methods()Arguments
- x
An object to write to file
- path
The file or connection to write to (dependent on part by method)
- method
The method of saving the file. When
default, the method is determined by file extension ofpath, if present, otherwise by the type of object ofx.- overwrite
When
NA, only saves if the md5 hashes do not match. Otherwise, seefs::file_copy().- quiet
When
TRUE, suppresses messages from md5 checks.- encoding
The encoding to use when writing the file.
- compression
The compression method to use when writing the file.
- ...
Additional arguments passed to the write function.
Value
write_file_md5():x, invisibly. Whenpathis not thestdout(),xis returned with the attribute"path"set to the result offile_copy_md5().mark_write_methods(): A list of applicable methods and their aliasesmark_compress_methods(): A character vector of applicable compression methods
options()
mark.compress.method: compression method to use when writing filesmark.list.hook: when adata.framecontains alistcolumn, this function is applied to each element of the list. The default"auto"usestoJSON()if the packagejsonliteis available, otherwise
Examples
# just writes to stdout()
df <- data.frame(a = 1, b = 2)
write_file_md5(df)
#> "a" "b"
#> 1 2
temp <- tempfile()
write_file_md5(df, temp) # new
#> <fileCopyMd5Message> /tmp/Rtmp0vvHCh/file1d156249aa5e (new file)
#> package:mark
write_file_md5(df, temp) # same
#> <fileCopyMd5Message> /tmp/Rtmp0vvHCh/file1d156249aa5e (md5 same)
#> package:mark
df$c <- 3
write_file_md5(df, temp) # changes
#> <fileCopyMd5Message> /tmp/Rtmp0vvHCh/file1d156249aa5e (md5 change)
#> package:mark
fs::file_delete(temp)