From 239eb91cc92bdea72b6b9957a7259e66017eaec1 Mon Sep 17 00:00:00 2001 From: Yihui Xie Date: Wed, 9 Oct 2024 08:54:34 -0500 Subject: [PATCH] use xfun::file_rename() --- DESCRIPTION | 4 ++-- R/latex.R | 10 +--------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 987899fa0..4abb05108 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: tinytex Type: Package Title: Helper Functions to Install and Maintain TeX Live, and Compile LaTeX Documents -Version: 0.53.1 +Version: 0.53.2 Authors@R: c( person("Yihui", "Xie", role = c("aut", "cre", "cph"), email = "xie@yihui.name", comment = c(ORCID = "0000-0003-0645-5666")), person(given = "Posit Software, PBC", role = c("cph", "fnd")), @@ -16,7 +16,7 @@ Description: Helper functions to install and maintain the 'LaTeX' distribution portable, and easy-to-maintain version of 'TeX Live'. This package also contains helper functions to compile 'LaTeX' documents, and install missing 'LaTeX' packages automatically. -Imports: xfun (>= 0.29) +Imports: xfun (>= 0.48) Suggests: testit, rstudioapi License: MIT + file LICENSE URL: https://github.com/rstudio/tinytex diff --git a/R/latex.R b/R/latex.R index e6fc6ca48..206003a8f 100644 --- a/R/latex.R +++ b/R/latex.R @@ -113,7 +113,7 @@ latexmk = function( if (is_latex) pdf_file = with_ext(pdf_file, 'dvi') check_pdf = function() { if (!file.exists(pdf)) show_latex_error(file, with_ext(pdf, 'log'), TRUE) - file_rename(pdf, pdf_file) + xfun::file_rename(pdf, pdf_file) pdf_file } if (engine == 'tectonic') { @@ -474,14 +474,6 @@ exist_files = function(files) { files[utils::file_test('-f', files)] } -# use file.copy() if file.rename() fails -file_rename = function(from, to) { - if (from == to) return(TRUE) - if (!suppressWarnings(file.rename(from, to))) { - if (file.copy(from, to, overwrite = TRUE)) file.remove(from) - } -} - #' Find missing LaTeX packages from a LaTeX log file #' #' Analyze the error messages in a LaTeX log file to figure out the names of