From 0fa48a2d2c66e6593ce7ec9ccb044a2905d2e17f Mon Sep 17 00:00:00 2001 From: Ian Lyttle Date: Sat, 3 Feb 2024 12:33:30 -0600 Subject: [PATCH] similar refactor for named files --- R/boxr_save_load.R | 4 ++-- R/boxr_write.R | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/R/boxr_save_load.R b/R/boxr_save_load.R index e8d8396..114004e 100644 --- a/R/boxr_save_load.R +++ b/R/boxr_save_load.R @@ -31,6 +31,7 @@ box_save <- function(..., dir_id = box_getwd(), file_name = ".RData", description = NULL) { + # using local_tempdir() to preserve the filename temp_file <- fs::path(withr::local_tempdir(), file_name) save(..., envir = parent.frame(), file = temp_file) @@ -58,8 +59,7 @@ box_save_image <- function(dir_id = box_getwd(), file_name = ".RData", } # using local_tempdir() to preserve the filename - temp_dir <- withr::local_tempdir() - temp_file <- fs::path(temp_dir, file_name) + temp_file <- fs::path(withr::local_tempdir(), file_name) save.image(file = temp_file) diff --git a/R/boxr_write.R b/R/boxr_write.R index 6287f43..b4d446f 100644 --- a/R/boxr_write.R +++ b/R/boxr_write.R @@ -69,9 +69,8 @@ box_write <- function(object, file_name, dir_id = box_getwd(), description = NUL } # using local_tempdir() to preserve the filename - temp_dir <- withr::local_tempdir() - temp_file <- fs::path(temp_dir, file_name) - + temp_file <- fs::path(withr::local_tempdir(), file_name) + write_fun(object, temp_file, ...) box_ul(dir_id = dir_id, file = temp_file, description = description) }