#' Get the 512k block size of a hard drive
#'
#' @note Updated 2022-09-06.
#' @noRd
#'
#' @examples
#' .blocks()
.blocks <- function(x = "/") {
x <- shell(
command = "df",
args = c("-P", "/"),
env = c("POSIXLY_CORRECT" = "1"),
print = FALSE
)
x <- x[["stdout"]]
x <- strsplit(x, split = "\\n")[[1L]][[2L]]
x <- strsplit(x = x, split = "[[:space:]]+", fixed = FALSE)[[1L]][[2L]]
x <- as.integer(x)
x
}
#' Split stdout string into a character vector
#'
#' @note Updated 2021-08-19.
#' @noRd
.splitStdout <- function(x) {
assert(
is.list(x),
isSubset("stdout", names(x))
)
strsplit(x = x[["stdout"]], split = "\n", fixed = TRUE)[[1L]]
}
#' Extract a simple string from stdout return
#'
#' @note Updated 2021-08-19.
#' @noRd
.stdoutString <- function(x) {
x <- .splitStdout(x)
assert(isString(x))
x
}
#' Unescape positional arguments
#'
#' @note Updated 2023-01-27.
#' @noRd
#'
#' @examples
#' x <- "mike'\\''s file"
#' .unescapePos(x)
.unescapePos <- function(x) {
x <- gsub(
pattern = "'\\''",
replacement = "'",
x = x,
fixed = TRUE
)
x
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.