Package 'flobr'

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

Help Index


Check flob

Description

Checks whether an object is a flob().

Usage

chk_flob(x, old = FALSE, x_name = NULL)

Arguments

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.

Value

NULL, invisibly. Called for the side effect of throwing an error if the condition is not met.

See Also

flobr() and chk_flob().

Examples

chk_flob(flobr::flob_obj)

Check slob

Description

Checks whether an object is a slob (serialized blob).

Usage

chk_slob(x, x_name = NULL)

Arguments

x

The object to check.

x_name

A string of the name of object x or NULL.

Value

NULL, invisibly. Called for the side effect of throwing an error if the condition is not met.

See Also

flobr() and chk_slob().

Examples

chk_slob(flobr:::slob_obj)

Flob File

Description

Converts a file into a flob. Flobs are useful for saving files in databases.

Usage

flob(path, name = "")

Arguments

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.

Details

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.

Value

A named flob of the file.

See Also

flobr()

Examples

path <- system.file("extdata", "flobr.pdf", package = "flobr")
flob <- flob(path)
flob

Flob Extension

Description

Flob Extension

Usage

flob_ext(flob)

Arguments

flob

A flob()

Value

A string of the extension of the original file.

See Also

flobr() and flob_name().

Examples

flob_ext(flob_obj)

Flob Name

Description

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".

Usage

flob_name(flob)

Arguments

flob

A flob()

Value

A character vector of the name of the file (without the extension).

See Also

flobr() and flob_ext().

Examples

flob_name(flob_obj)

A flob Object

Description

A flob() of 'inst/extdata/flobr.pdf'.

Usage

flob_obj

Format

An object of class flob (inherits from blob) of length 1.

Examples

flob_obj

Is flob

Description

Is flob

Usage

is_flob(x)

Arguments

x

An object to test

Value

A flag indicating whether x inherits from flob().

See Also

flobr()

Examples

is_flob(flob_obj)

Unflob to File

Description

Converts a flob() back to its original file format.

Usage

unflob(flob, dir = ".", name = "", ext = "", slob = FALSE, check = TRUE)

Arguments

flob

The flob() to save to file.

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.

Details

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.

Value

An invisible string of the path to the saved file.

Examples

unflob(flob_obj, tempdir())

Validate flob Object

Description

Validates a flob() object.

Usage

vld_flob(x, old = FALSE)

Arguments

x

The object to check.

old

A flag indicating whether old flobs are permitted.

Value

A flag indicating whether the object passed the test.

See Also

chk_flob()

Examples

vld_flob(flobr::flob_obj)
vld_flob(1)