Code
if (bdIsFileLocked("data.h5")) stop("File in use")bdIsLocked_hdf5
HDF5_IO_MANAGEMENT
Uses HDF5 file locking to check if filename can be opened in read/write mode. If opening fails under locking, the file is treated as “in use” and TRUE is returned. Non-existent files return FALSE.
| Parameter | Description |
|---|---|
filename |
Character. Path to the HDF5 file. |
Logical scalar: if locked/in use, otherwise.
Requires HDF5 file locking (HDF5 >= 1.12 recommended). The function sets HDF5_USE_FILE_LOCKING=TRUE for the process.
---
title: "bdIsLocked_hdf5"
subtitle: "bdIsLocked_hdf5"
---
<span class="category-badge hdf5_io_management">HDF5_IO_MANAGEMENT</span>
## Description
Uses HDF5 file locking to check if `filename` can be opened in
read/write mode. If opening fails under locking, the file is treated
as "in use" and `TRUE` is returned. Non-existent files return
`FALSE`.
## Usage
```r
bdIsLocked_hdf5(filename)
```
## Arguments
::: {.param-table}
| Parameter | Description |
|-----------|-------------|
| `filename` | Character. Path to the HDF5 file. |
:::
## Value
::: {.return-value}
Logical scalar: \code{TRUE} if locked/in use, \code{FALSE} otherwise.
:::
## Details
Requires HDF5 file locking (HDF5 >= 1.12 recommended). The
function sets `HDF5_USE_FILE_LOCKING=TRUE` for the process.
## Examples
```{r}
#| eval: false
#| code-fold: show
if (bdIsFileLocked("data.h5")) stop("File in use")
```