Skip to content

Commit

Permalink
Try first creating the temporary directory and, then, building the te…
Browse files Browse the repository at this point in the history
…mpfile in the temporary directory with an extension.

Delete the file when the function exits.
  • Loading branch information
coatless committed Sep 4, 2024
1 parent a60850a commit 082673b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions R/surreal-text.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ temporary_text_plot <- function(text, cex = 4) {
# Replace empty spaces with double dots for better visibility
# text <- gsub("", "..", text)

# Create a temporary file path
temp_file <- tempfile()
# Create a temporary file path using a known directory
temp_dir <- tempdir()
temp_file <- tempfile(tmpdir = temp_dir, fileext = ".ppm")

# Ensure the temporary file is removed when the function exits
on.exit(unlink(temp_file))

# Create a bitmap image
bitmap(temp_file, "ppm", height = 5, width = 5)
Expand Down

0 comments on commit 082673b

Please sign in to comment.