
Check if an Excel file is open and execute a read function
Source:R/utilASRopencheck.R
utilASRopencheck.RdCheck if an Excel file is open and execute a read function
Details
First checks for lock files created by Excel (~$filename) and
LibreOffice (.~lock.filename#). If none are found, calls fn()
and catches the utils::unzip error that occurs when Excel holds an
OS-level lock without creating a local lock file (e.g. on OneDrive). Both
paths produce the same user-facing message.
Examples
contpth <- system.file('extdata/ExampleCont1.xlsx', package = 'AquaSensR')
utilASRopencheck(contpth, \() readxl::read_excel(contpth, n_max = 0))
#> # A tibble: 0 × 9
#> # ℹ 9 variables: Date <lgl>, Time <lgl>, Water_Temp_C <lgl>, DO_pctsat <lgl>,
#> # DO_mg_l <lgl>, Conductivity_uS_cm <lgl>, TDS_mg_l <lgl>,
#> # Salinity_ppt <lgl>, pH_SU <lgl>