Title: | Convert Files to and from Binary Objects (BLOBs) |
---|---|
Description: | Converts files to and from flobs. A flob is a file that was read into binary in integer-mode as little endian, saved as the single element of a named list (where the name is the name of the original file) and then serialized before being coerced into a blob. Flobs are useful for writing and reading files to and from databases. |
Authors: | Evan Amies-Galonski [aut, cre] , Joe Thorley [aut] , Poisson Consulting [cph, fnd] |
Maintainer: | Evan Amies-Galonski <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.2.3.9000 |
Built: | 2024-11-04 21:16:23 UTC |
Source: | https://github.com/poissonconsulting/flobr |
Checks whether an object is a flob()
.
chk_flob(x, old = FALSE, x_name = NULL)
chk_flob(x, old = FALSE, x_name = NULL)
x |
The object to check. |
old |
A flag indicating whether old flobs are permitted. |
x_name |
A string of the name of object x or NULL. |
NULL
, invisibly. Called for the side effect of throwing an error
if the condition is not met.
flobr()
and chk_flob()
.
chk_flob(flobr::flob_obj)
chk_flob(flobr::flob_obj)
Checks whether an object is a slob (serialized blob).
chk_slob(x, x_name = NULL)
chk_slob(x, x_name = NULL)
x |
The object to check. |
x_name |
A string of the name of object x or NULL. |
NULL
, invisibly. Called for the side effect of throwing an error
if the condition is not met.
flobr()
and chk_slob()
.
chk_slob(flobr:::slob_obj)
chk_slob(flobr:::slob_obj)
Converts a file into a flob. Flobs are useful for saving files in databases.
flob(path, name = "")
flob(path, name = "")
path |
A string of the path to the file. |
name |
A string of the name (without the extension) for the flob. If "" (the default) then the original file name is used. |
A flob is a file that was read into binary in integer-mode as little endian, saved as the single element of a named list (where the name is the extension of the original file) and then serialized before being coerced into a blob.
A named flob of the file.
path <- system.file("extdata", "flobr.pdf", package = "flobr") flob <- flob(path) flob
path <- system.file("extdata", "flobr.pdf", package = "flobr") flob <- flob(path) flob
Flob Extension
flob_ext(flob)
flob_ext(flob)
flob |
A |
A string of the extension of the original file.
flobr()
and flob_name()
.
flob_ext(flob_obj)
flob_ext(flob_obj)
Gets a character vector of the name of the file (without the extension). If the flob does not have a file name it returns "file".
flob_name(flob)
flob_name(flob)
flob |
A |
A character vector of the name of the file (without the extension).
flobr()
and flob_ext()
.
flob_name(flob_obj)
flob_name(flob_obj)
A flob()
of 'inst/extdata/flobr.pdf'
.
flob_obj
flob_obj
An object of class flob
(inherits from blob
) of length 1.
flob_obj
flob_obj
Converts a flob()
back to its original file format.
unflob(flob, dir = ".", name = "", ext = "", slob = FALSE, check = TRUE)
unflob(flob, dir = ".", name = "", ext = "", slob = FALSE, check = TRUE)
flob |
The |
dir |
A string of the path to the directory to save the file in. |
name |
A string of the name (without the extension) for the file. If "" (the default) then the original file name is used. |
ext |
A string of the extension for the file. If "" (the default) then the original extension is used. |
slob |
A logical scalar specifying whether to process slobs (serialized blobs) instead of flobs. If NA, either will be accepted, but slobs require that ext and name be provided. |
check |
A flag indicating whether to run comprehensive checks on user input. |
If path ends with a file separator then the name and extension of the flob is added. If the flob is an older flob that was not saved with a name then it is named 'file'.
If path ends with a file name without an extension then the extension of the flob is automatically added. Alternatively if path also includes an extension then it must match the flob's extension.
An invisible string of the path to the saved file.
unflob(flob_obj, tempdir())
unflob(flob_obj, tempdir())
Validates a flob()
object.
vld_flob(x, old = FALSE)
vld_flob(x, old = FALSE)
x |
The object to check. |
old |
A flag indicating whether old flobs are permitted. |
A flag indicating whether the object passed the test.
vld_flob(flobr::flob_obj) vld_flob(1)
vld_flob(flobr::flob_obj) vld_flob(1)